Struct bindgen::Builder [] [src]

pub struct Builder { /* fields omitted */ }

Configure and generate Rust bindings for a C/C++ header.

This is the main entry point to the library.

use bindgen::builder;

// Configure and generate bindings.
let bindings = try!(builder().header("path/to/input/header")
                             .whitelisted_type("SomeCoolClass")
                             .whitelisted_function("do_some_cool_thing")
                             .generate());

// Write the generated bindings to an output file.
try!(bindings.write_to_file("path/to/output.rs"));

Methods

impl Builder
[src]

Set the input C/C++ header.

Whether the generated bindings should contain documentation comments or not.

This ideally will always be true, but it may need to be false until we implement some processing on comments to work around issues as described in:

https://github.com/servo/rust-bindgen/issues/426

Whether to whitelist types recursively or not. Defaults to true.

This can be used to get bindgen to generate exactly the types you want in your bindings, and then import other types manually via other means (like raw_line).

Generate a C/C++ file that includes the header and has dummy uses of every type defined in the header.

Hide the given type from the generated bindings. Regular expressions are supported.

Treat the given type as opaque in the generated bindings. Regular expressions are supported.

Whitelist the given type so that it (and all types that it transitively refers to) appears in the generated bindings. Regular expressions are supported.

Whitelist the given function so that it (and all types that it transitively refers to) appears in the generated bindings. Regular expressions are supported.

Whitelist the given variable so that it (and all types that it transitively refers to) appears in the generated bindings. Regular expressions are supported.

Mark the given enum (or set of enums, if using a pattern) as being bitfield-like. Regular expressions are supported.

This makes bindgen generate a type that isn't a rust enum. Regular expressions are supported.

Mark the given enum (or set of enums, if using a pattern) as being constant.

This makes bindgen generate constants instead of enums. Regular expressions are supported.

Add a string to prepend to the generated bindings. The string is passed through without any modification.

Add an argument to be passed straight through to clang.

Make the generated bindings link the given shared library.

Make the generated bindings link the given static library.

Make the generated bindings link the given framework.

Emit bindings for builtin definitions (for example __builtin_va_list) in the generated Rust.

Avoid converting floats to f32/f64 by default.

Set whether Debug should be derived by default.

Emit Clang AST.

Emit IR.

Enable C++ namespaces.

Disable auto-namespacing of names if namespaces are disabled.

By default, if namespaces are disabled, bindgen tries to mangle the names to from foo::bar::Baz to look like foo_bar_Baz, instead of just Baz.

This option disables that behavior.

Note that this intentionally doesn't change the names using for whitelisting and blacklisting, that should still be mangled with the namespaces.

Note, also, that using this option may cause duplicated names to be generated.

Treat inline namespaces conservatively.

This is tricky, because in C++ is technically legal to override an item defined in an inline namespace:

inline namespace foo {
    using Bar = int;
}
using Bar = long;

Even though referencing Bar is a compiler error.

We want to support this (arguably esoteric) use case, but we don't want to make the rest of bindgen users pay an usability penalty for that.

To support this, we need to keep all the inline namespaces around, but then bindgen usage is a bit more difficult, because you cannot reference, e.g., std::string (you'd need to use the proper inline namespace).

We could complicate a lot of the logic to detect name collisions, and if not detected generate a pub use inline_ns::* or something like that.

That's probably something we can do if we see this option is needed in a lot of cases, to improve it's usability, but my guess is that this is not going to be too useful.

Ignore functions.

Ignore methods.

Avoid generating any unstable Rust, such as Rust unions, in the generated bindings.

Use core instead of libstd in the generated bindings.

Use the given prefix for the raw types instead of ::std::os::raw.

Allows configuring types in different situations, see the TypeChooser documentation.

Choose what to generate using a CodegenConfig.

Generate the Rust bindings using the options built up thus far.

Trait Implementations

impl Debug for Builder
[src]

Formats the value using the given formatter.

impl Default for Builder
[src]

Returns the "default value" for a type. Read more