Struct libbindgen::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]
fn header<T: Into<String>>(self, header: T) -> Builder
Set the input C/C++ header.
fn dummy_uses<T: Into<String>>(self, dummy_uses: T) -> Builder
Generate a C/C++ file that includes the header and has dummy uses of every type defined in the header.
fn hide_type<T: Into<String>>(self, arg: T) -> Builder
Hide the given type from the generated bindings.
fn opaque_type<T: Into<String>>(self, arg: T) -> Builder
Treat the given type as opaque in the generated bindings.
fn whitelisted_type<T: Borrow<str>>(self, arg: T) -> Builder
Whitelist the given type so that it (and all types that it transitively refers to) appears in the generated bindings.
fn whitelisted_function<T: Borrow<str>>(self, arg: T) -> Builder
Whitelist the given function so that it (and all types that it transitively refers to) appears in the generated bindings.
fn whitelisted_var<T: Borrow<str>>(self, arg: T) -> Builder
Whitelist the given variable so that it (and all types that it transitively refers to) appears in the generated bindings.
fn bitfield_enum<T: Borrow<str>>(self, arg: T) -> Builder
Mark the given enum (or set of enums, if using a pattern) as being bitfield-like.
This makes bindgen generate a type that isn't a rust enum
.
fn raw_line<T: Into<String>>(self, arg: T) -> Builder
Add a string to prepend to the generated bindings. The string is passed through without any modification.
fn clang_arg<T: Into<String>>(self, arg: T) -> Builder
Add an argument to be passed straight through to clang.
fn link<T: Into<String>>(self, library: T) -> Builder
Make the generated bindings link the given shared library.
fn link_static<T: Into<String>>(self, library: T) -> Builder
Make the generated bindings link the given static library.
fn link_framework<T: Into<String>>(self, library: T) -> Builder
Make the generated bindings link the given framework.
fn emit_builtins(self) -> Builder
Emit bindings for builtin definitions (for example __builtin_va_list
)
in the generated Rust.
fn no_convert_floats(self) -> Self
Avoid converting floats to f32/f64 by default.
fn emit_clang_ast(self) -> Builder
Emit Clang AST.
fn emit_ir(self) -> Builder
Emit IR.
fn enable_cxx_namespaces(self) -> Builder
Enable C++ namespaces.
fn disable_name_namespacing(self) -> Builder
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.
fn ignore_functions(self) -> Builder
Ignore functions.
fn ignore_methods(self) -> Builder
Ignore methods.
fn no_unstable_rust(self) -> Builder
Avoid generating any unstable Rust in the generated bindings.
fn use_core(self) -> Builder
Use core instead of libstd in the generated bindings.
fn ctypes_prefix<T: Into<String>>(self, prefix: T) -> Builder
Use the given prefix for the raw types instead of ::std::os::raw
.
fn type_chooser(self, cb: Box<TypeChooser>) -> Self
Allows configuring types in different situations, see the TypeChooser
documentation.
fn with_codegen_config(self, config: CodegenConfig) -> Self
Choose what to generate using a CodegenConfig.
fn generate<'ctx>(self) -> Result<Bindings<'ctx>, ()>
Generate the Rust bindings using the options built up thus far.