gecko-dev/third_party/rust/bindgen/README.md
Emilio Cobos Álvarez 4fa90b8c5b Bug 1341102: Revendor rust dependencies on a CLOSED TREE. r=red
MozReview-Commit-ID: GrqpxUECOtt


--HG--
rename : third_party/rust/bitflags/.cargo-checksum.json => third_party/rust/bitflags-0.7.0/.cargo-checksum.json
rename : third_party/rust/bitflags/.travis.yml => third_party/rust/bitflags-0.7.0/.travis.yml
rename : third_party/rust/bitflags/Cargo.toml => third_party/rust/bitflags-0.7.0/Cargo.toml
rename : third_party/rust/dtoa/LICENSE-APACHE => third_party/rust/bitflags-0.7.0/LICENSE-APACHE
rename : third_party/rust/serde_json/LICENSE-MIT => third_party/rust/bitflags-0.7.0/LICENSE-MIT
rename : third_party/rust/bitflags/README.md => third_party/rust/bitflags-0.7.0/README.md
rename : third_party/rust/bitflags/src/lib.rs => third_party/rust/bitflags-0.7.0/src/lib.rs
rename : third_party/rust/itoa/LICENSE-APACHE => third_party/rust/syntex/LICENSE-APACHE
rename : third_party/rust/serde_json/LICENSE-MIT => third_party/rust/syntex/LICENSE-MIT
rename : third_party/rust/serde_json/LICENSE-APACHE => third_party/rust/syntex_errors/LICENSE-APACHE
rename : third_party/rust/serde_json/LICENSE-MIT => third_party/rust/syntex_errors/LICENSE-MIT
rename : third_party/rust/dtoa/LICENSE-APACHE => third_party/rust/syntex_pos/LICENSE-APACHE
rename : third_party/rust/serde_json/LICENSE-MIT => third_party/rust/syntex_pos/LICENSE-MIT
rename : third_party/rust/dtoa/LICENSE-APACHE => third_party/rust/syntex_syntax/LICENSE-APACHE
rename : third_party/rust/serde_json/LICENSE-MIT => third_party/rust/syntex_syntax/LICENSE-MIT
2017-05-08 21:05:42 +02:00

982 B

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

Contributing

See CONTRIBUTING.md for hacking on bindgen!