pub struct Ferment { /* private fields */ }Implementations§
Source§impl Builder
impl Builder
pub fn new(current_crate: Crate) -> Builder
pub fn with_crate_name(crate_name: &str) -> Builder
pub fn with_default_mod_name(self) -> Builder
pub fn with_cbindgen_config(self, config: Config) -> Builder
pub fn with_cbindgen_config_from_file(self, config: &'static str) -> Builder
pub fn with_mod_name<S: AsRef<str>>(self, mod_name: S) -> Builder
pub fn with_crates(self, crates: Vec<&str>) -> Builder
pub fn with_external_crates(self, crates: Vec<&str>) -> Builder
pub fn with_languages(self, languages: Vec<Lang>) -> Builder
Sourcepub fn generate(self) -> Result<(), Error>
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}.rsand will be located inside thesrc/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.