tskit/
bindings.rs

1//! Low-level ("unsafe") bindings to the C API.
2//!
3//! This module is a 1-to-1 mapping of C types
4//! and functions for both tskit and kastore.
5//! The bindings are generate via [bindgen](https://docs.rs/bindgen).
6//!
7//! Using things from this module will be ``unsafe``.
8//! Further, as many of the types require ``init()`` methods
9//! to correctly set up the structs, one has to coerce ``rust``
10//! into allowing uninitialized variables:
11//!
12//! ```
13//! use std::mem::MaybeUninit;
14//! let mut edges: MaybeUninit<tskit::bindings::tsk_edge_table_t> = MaybeUninit::uninit();
15//! unsafe {
16//!     let _ = tskit::bindings::tsk_edge_table_init(edges.as_mut_ptr(), 0);
17//!     let _ = tskit::bindings::tsk_edge_table_add_row(edges.as_mut_ptr(), 0., 10., 0, 1, std::ptr::null(), 0);
18//!     assert_eq!((*edges.as_ptr()).num_rows, 1);
19//!     tskit::bindings::tsk_edge_table_free(edges.as_mut_ptr());
20//! }
21//! ```
22//!
23//! The best source for documentation will be the [tskit docs](https://tskit.readthedocs.io).
24//! Those docs describe the most important parts of the C API.
25//! This module contains the same types/functions with the same names.
26
27#![allow(clippy::all)]
28
29include!(concat!(env!("OUT_DIR"), "/auto_bindings.rs"));