Struct Generator

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

Generator is a main point of flapigen. It expands rust macroses and generates not rust code. It designed to use inside build.rs.

Implementations§

Source§

impl Generator

Source

pub fn new(config: LanguageConfig) -> Generator

Source

pub fn with_pointer_target_width(self, pointer_target_width: usize) -> Self

By default we get pointer_target_width via cargo (more exactly CARGO_CFG_TARGET_POINTER_WIDTH), but you can change default value via this method

Source

pub fn rustfmt_bindings(self, doit: bool) -> Self

Set whether rustfmt should format the generated bindings.

Source

pub fn remove_not_generated_files_from_output_directory( self, doit: bool, ) -> Self

If true removes not generated by flapigen files from output directory, suitable for removing obsolete files. Warning! May remove your files if turn on, so by default false

Source

pub fn merge_type_map(self, id_of_code: &str, code: &str) -> Self

Add new foreign langauge type <-> Rust mapping

Source

pub fn register_class_attribute_callback<F>( self, attr_name: &str, cb: F, ) -> Self
where F: Fn(&mut Vec<u8>, &str) + 'static,

Register callback to extend/modify class, if foreign_class has #[derive(attr_name)] then after foreign code generation cb would be called, with full code of module, plus class name

Source

pub fn register_enum_attribute_callback<F>(self, attr_name: &str, cb: F) -> Self
where F: Fn(&mut Vec<u8>, &str) + 'static,

Register callback to extend/modify enum, if foreign_enum has #[derive(attr_name)] then after foreign code generation cb would be called, with full code of module, plus enum name

Source

pub fn register_method_attribute_callback<F>( self, attr_name: &str, cb: F, ) -> Self
where F: Fn(&mut Vec<u8>, MethodInfo<'_>) + 'static,

Register callback to extend/modify method of class, if fn inside foreign_class has attribute, then after foreign code generation cb would be called with full code of moulde, plus class name, plus method name

Source

pub fn expand<S, D>(self, crate_name: &str, src: S, dst: D)
where S: AsRef<Path>, D: AsRef<Path>,

process src and save result of macro expansion to dst

§Panics

Panics on error

Source

pub fn expand_many<S, D>(self, crate_name: &str, srcs: &[S], dst: D)
where S: AsRef<Path>, D: AsRef<Path>,

process srcs and save result of macro expansion to dst

§Panics

Panics on error

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.