Struct Generator

Source
pub struct Generator { /* private fields */ }
Expand description

Builder struct for configuring and generating bindings.

Implementations§

Source§

impl Generator

Source

pub fn include_path<T: AsRef<Path>>(self, path: T) -> Self

Adds path to the list of include paths to pass to libclang.

Source

pub fn target<T: AsRef<str>>(self, target: T) -> Self

Specify the target triple for which bindings should be generated.

Source

pub fn skip_type<T: AsRef<str>>(self, type_: T) -> Self

Do not generate bindings for type_.

Source

pub fn skip_types<S: AsRef<str>, T: AsRef<[S]>>(self, types: T) -> Self

Do not generate bindings for types.

Source

pub fn skip_interface_trait<T: AsRef<str>>(self, interface: T) -> Self

Do not generate an interface trait for interface.

Source

pub fn skip_interface_traits<'a, T: AsRef<[&'a str]>>( self, interfaces: T, ) -> Self

Do not generate interface traits for interfaces.

Source

pub fn constant_parser<F>(self, f: F) -> Self
where F: Fn(&[String]) -> Option<String> + 'static,

Registers a callback for parsing constant definitions which libclang is not able to evaluate.

The callback will be passed a slice of tokens, and its output (if not None) will be included in the generated bindings.

Source

pub fn iid_generator<F>(self, f: F) -> Self
where F: Fn(&str) -> String + 'static,

Registers a callback which should, when given the name of an interface as a string, return a string containing a Rust expression evaluating to the Guid value for that interface.

Source

pub fn query_interface_fn<T: AsRef<str>>(self, f: T) -> Self

Registers a function which will be called by the implementations of Unknown::query_interface for generated interface types.

The function should be in scope where the resulting bindings are placed, and it should have the same type signature as Unknown::query_interface.

Source

pub fn add_ref_fn<T: AsRef<str>>(self, f: T) -> Self

Registers a function which will be called by the implementations of Unknown::add_ref for generated interface types.

The function should be in scope where the resulting bindings are placed, and it should have the same type signature as Unknown::add_ref.

Source

pub fn release_fn<T: AsRef<str>>(self, f: T) -> Self

Registers a function which will be called by the implementations of Unknown::release for generated interface types.

The function should be in scope where the resulting bindings are placed, and it should have the same type signature as Unknown::release.

Source

pub fn generate<T: AsRef<str>, W: Write>( &self, source: T, sink: W, ) -> Result<(), Box<dyn Error>>

Generates Rust bindings for the C++ definitions in source and outputs them via sink.

Trait Implementations§

Source§

impl Default for Generator

Source§

fn default() -> Generator

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.