diff options
-rw-r--r-- | README.md | 24 |
1 files changed, 11 insertions, 13 deletions
@@ -2,33 +2,31 @@ **`bindgen` automatically generates Rust FFI bindings to C and C++ libraries.** -For example, given the C header `cool.h`: +For example, given the C header `doggo.h`: ```c -typedef struct CoolStruct { - int x; - int y; -} CoolStruct; +typedef struct Doggo { + int many; + char wow; +} Doggo; -void cool_function(int i, char c, CoolStruct* cs); +void eleven_out_of_ten_majestic_af(Doggo* pupper); ``` -`bindgen` produces Rust FFI code allowing you to call into the `cool` library's +`bindgen` produces Rust FFI code allowing you to call into the `doggo` library's functions and use its types: ```rust /* automatically generated by rust-bindgen */ #[repr(C)] -pub struct CoolStruct { - pub x: ::std::os::raw::c_int, - pub y: ::std::os::raw::c_int, +pub struct Doggo { + pub many: ::std::os::raw::c_int, + pub wow: ::std::os::raw::c_char, } extern "C" { - pub fn cool_function(i: ::std::os::raw::c_int, - c: ::std::os::raw::c_char, - cs: *mut CoolStruct); + pub fn eleven_out_of_ten_majestic_af(pupper: *mut Doggo); } ``` |