Struct Builder

Source
pub struct Builder { /* private fields */ }

Implementations§

Source§

impl Builder

Source

pub fn new(current_crate: Crate) -> Builder

Source

pub fn with_crate_name(crate_name: &str) -> Builder

Source

pub fn with_default_mod_name(self) -> Builder

Source

pub fn with_cbindgen_config(self, config: Config) -> Builder

Source

pub fn with_cbindgen_config_from_file(self, config: &'static str) -> Builder

Source

pub fn with_mod_name<S: AsRef<str>>(self, mod_name: S) -> Builder

Source

pub fn with_crates(self, crates: Vec<&str>) -> Builder

Source

pub fn with_external_crates(self, crates: Vec<&str>) -> Builder

Source

pub fn with_languages(self, languages: Vec<Lang>) -> Builder

Source

pub fn generate(self) -> Result<(), Error>

Reads rust file and its nested dependencies Creates syntax tree which we’ll use later to handle imports for FFI converted types mod_name: mod with this name will be created in src/{mod_name}.rs

Recursively reads a Rust project file tree and its nested dependencies to generate a syntax tree.

This function will traverse the primary Rust file and its dependencies to generate a syntax tree. This tree is later utilized to manage imports for types that are converted for FFI.

The resulting code will be written into a new module file in the src/ directory.

§Arguments
  • mod_name: The name of the module to be created. The resulting file will be named {mod_name}.rs and will be located inside the src/ directory.
§Errors

If the function encounters any errors while reading the file, processing the syntax, or writing to the output file, it will return an error::Error.

§Example
use ferment_sys::{Crate, Ferment, Lang};
let mut languages = vec![];
#[cfg(feature = "objc")]
languages.push(Lang::ObjC(ferment::ObjC::new("DS", "Fermented")));
#[cfg(feature = "java")]
languages.push(Lang::Java(ferment::Java::new("Fermented")));
Ferment::with_crate_name("your_crate_name")
    .with_default_mod_name()
    .with_crates(vec![])
    .with_languages(languages)
    .generate()
    .expect("Fermentation fault");
§Remarks

This function expects the primary Rust file to be named lib.rs and located inside the src/ directory. Any deviation from this naming and structure might lead to errors.

The resulting module will only contain the necessary imports and types suitable for FFI conversion.

Trait Implementations§

Source§

impl Clone for Builder

Source§

fn clone(&self) -> Builder

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Builder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.