#bindings #ffi #code-generation

build bindgen

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

84 releases (37 breaking)

0.52.0 Nov 19, 2019
0.51.0 Jul 26, 2019
0.50.1 Sep 23, 2019
0.49.4 Dec 4, 2019
0.0.2 Nov 21, 2014

#1 in FFI

Download history 26926/week @ 2019-10-04 27654/week @ 2019-10-11 27309/week @ 2019-10-18 28322/week @ 2019-10-25 27704/week @ 2019-11-01 29356/week @ 2019-11-08 28848/week @ 2019-11-15 29867/week @ 2019-11-22 28595/week @ 2019-11-29 31627/week @ 2019-12-06 31075/week @ 2019-12-13 17390/week @ 2019-12-20 16130/week @ 2019-12-27 31051/week @ 2020-01-03 28999/week @ 2020-01-10

120,445 downloads per month
Used in 1,021 crates (502 directly)

BSD-3-Clause

1MB
19K 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

~3.5MB
~77K SLoC