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