mirror of
https://gitee.com/openharmony/third_party_rust_bindgen
synced 2024-12-12 09:46:23 +00:00
.github | ||
bindgen-integration | ||
book | ||
ci | ||
csmith-fuzzing | ||
releases | ||
src | ||
tests | ||
.gitattributes | ||
.gitignore | ||
.travis.yml | ||
appveyor.yml | ||
build.rs | ||
Cargo.lock | ||
Cargo.toml | ||
CHANGELOG.md | ||
CONTRIBUTING.md | ||
example-graphviz-ir.png | ||
LICENSE | ||
README.md | ||
rustfmt.toml |
bindgen
bindgen
automatically generates Rust FFI bindings to C (and some C++) libraries.
For example, given the C header doggo.h
:
typedef struct Doggo {
int many;
char wow;
} Doggo;
void eleven_out_of_ten_majestic_af(Doggo* pupper);
bindgen
produces Rust FFI code allowing you to call into the doggo
library's
functions and use its types:
/* automatically generated by rust-bindgen */
#[repr(C)]
pub struct Doggo {
pub many: ::std::os::raw::c_int,
pub wow: ::std::os::raw::c_char,
}
extern "C" {
pub fn eleven_out_of_ten_majestic_af(pupper: *mut Doggo);
}
Users Guide
📚 Read the bindgen
users guide here! 📚
API Reference
API reference documentation is on docs.rs