#bindings #ffi #code-generation

build bindgen

Automatically generates Rust FFI bindings to C and C++ libraries

77 releases (34 breaking)

0.49.2 May 22, 2019
0.49.0 Mar 27, 2019
0.46.0 Dec 29, 2018
0.44.0 Nov 30, 2018
0.0.2 Nov 21, 2014

#1 in FFI

Download history 10075/week @ 2019-02-06 10840/week @ 2019-02-13 10942/week @ 2019-02-20 10990/week @ 2019-02-27 12611/week @ 2019-03-06 12866/week @ 2019-03-13 11932/week @ 2019-03-20 11901/week @ 2019-03-27 11741/week @ 2019-04-03 13867/week @ 2019-04-10 13147/week @ 2019-04-17 15103/week @ 2019-04-24 12168/week @ 2019-05-01 12803/week @ 2019-05-08 11918/week @ 2019-05-15

55,361 downloads per month
Used in 734 crates (376 directly)

BSD-3-Clause

1MB
18K SLoC

crates.io docs.rs

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

Contributing

See CONTRIBUTING.md for hacking on bindgen!

Dependencies

~5MB
~80K SLoC