1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! Generate traits from C header files.
//!
//! When rewriting a C libary in Rust,
//! you often want to preserve the original C header files.
//!
//! This is possible using this crate in conjuction with [`bindgen`](https://docs.rs/bindgen).
//!
//! Take the following `C` header.
//!
//! ```c
//! ```
//!
//! In your `build.rs` script:
//! 1. Use [`bindgen`](https://docs.rs/bindgen) to generate equivalent Rust blocks.
//! 2. Use [`seesaw`] to generate a trait from those bindings.
//!
//! ```no_run
//! // build.rs
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let bindings = bindgen::builder().header("yakshaver.h").generate()?;
//! seesaw::seesaw("Yakshaver", &bindings, "generated/seesaw.rs")?;
//! bindings.write_to_file("generated/bindgen.rs")?;
//! # Ok(())
//! # }
//! ```
//!
//! The generated file will look like this:
//!
//! ```
//! # struct yakshaver;
//! ```
//!
//! And you can export the same ABI as the C library using [`no_mangle`],
//! which simply adds `#[no_mangle]` to each of the functions.
//!
//! ```
//! # const _: &str = stringify! {
//! #[seesaw::no_mangle]
//! impl YakShaver for () { .. }
//! # };
//! ```
pub use no_mangle;
pub use ;