#divecomputer #libdivecomputer #libdivecomputer-sys

sys libdivecomputer-sys

Unsafe bindings for libdivecomputer

1 unstable release

Uses new Rust 2024

new 0.1.0 Apr 17, 2025
Download history 109/week @ 2025-04-12

109 downloads per month
Used in libdivecomputer

(MIT OR Apache-2.0) AND LGPL-2.1

2MB
45K SLoC

C 44K SLoC // 0.1% comments Visual Studio Project 407 SLoC Automake 274 SLoC M4 159 SLoC // 0.6% comments Rust 95 SLoC // 0.2% comments Snakemake 18 SLoC // 0.3% comments Shell 1 SLoC

Contains (obscure autoconf code, 8KB) libdivecomputer/configure.ac

🧭 libdivecomputer-sys

Unsafe automatically-generated Rust bindings for libdivecomputer.

Build Status Crates.io Docs

Please also see the repository containing a work-in-progress safe wrapper.

Basic usage

unsafe {
    let mut iterator: *mut dc_iterator_t = ptr::null_mut();
    let mut descriptor: *mut dc_descriptor_t = ptr::null_mut();

    dc_descriptor_iterator(&mut iterator);
    while dc_iterator_next(iterator, &mut descriptor as *mut _ as *mut c_void)
        == dc_status_t_DC_STATUS_SUCCESS
    {
        let vendor = CStr::from_ptr(dc_descriptor_get_vendor(descriptor));
        let product = CStr::from_ptr(dc_descriptor_get_product(descriptor));

        println!("{} {}", vendor.to_string_lossy(), product.to_string_lossy());

        dc_descriptor_free(descriptor);
    }
    dc_iterator_free(iterator);
}

License

Licensed under either of

at your option.

Note that libdivecomputer has its own LGPL-2.1 license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

No runtime deps

~0–2MB
~38K SLoC