pub struct Builder<'__, W> { /* private fields */ }
headers
only.Implementations§
source§impl<'__, W> Builder<'__, W>
impl<'__, W> Builder<'__, W>
sourcepub fn with_guard(self, guard: &'__ str) -> Self
pub fn with_guard(self, guard: &'__ str) -> Self
Sets up the name of the ifndef
guard of the header file.
It defaults to:
format!("__RUST_{}__", env::var("CARGO_CRATE_NAME")?.replace("-", "_").to_ascii_uppercase())
sourcepub fn with_text_after_guard(self, text_after_guard: &'__ str) -> Self
pub fn with_text_after_guard(self, text_after_guard: &'__ str) -> Self
Text included after the include guard of the header file
It defaults to an empty string
Sets up the banner of the generated C header file.
It defaults to:
concat!(
"/*! \\file */\n",
"/*******************************************\n",
" * *\n",
" * File auto-generated by `::safer_ffi`. *\n",
" * *\n",
" * Do not manually edit this file. *\n",
" * *\n",
" *******************************************/\n",
)
/*! \file */ /******************************************* * * * File auto-generated by `::safer_ffi`. * * * * Do not manually edit this file. * * * *******************************************/
sourcepub fn with_language(self, language: Language) -> Self
pub fn with_language(self, language: Language) -> Self
Sets the Language
of the generated headers.
It defaults to Language::C
.
sourcepub fn with_naming_convention(self, naming_convention: NamingConvention) -> Self
pub fn with_naming_convention(self, naming_convention: NamingConvention) -> Self
Sets prefix for generated functions, structs & enums
sourcepub fn with_stable_header(self, stable_header: bool) -> Self
pub fn with_stable_header(self, stable_header: bool) -> Self
Whether to yield a stable header or not (order of defined items guaranteed not to change provided the source code doesn’t change either).
It defaults to true
.
source§impl<'__> Builder<'__, WhereTo>
impl<'__> Builder<'__, WhereTo>
sourcepub fn to_file(self, filename: impl AsRef<Path>) -> Result<Builder<'__, File>>
pub fn to_file(self, filename: impl AsRef<Path>) -> Result<Builder<'__, File>>
Specify the path to the file to be generated.
⚠️ If it already exists, its contents will be overwritten ⚠️
There is no default value here, either .to_file()
or .to_writer()
need to be called to be able to .generate()
the headers.
For more fine-grained control over the “output stream” where the
headers will be written to, use .to_writer()
.
Example
::safer_ffi::headers::builder()
.to_file("my_header.h")?
.generate()?
source§impl Builder<'_, WhereTo>
impl Builder<'_, WhereTo>
sourcepub fn generate_with_definer(self, definer: &mut impl Definer) -> Result<()>
pub fn generate_with_definer(self, definer: &mut impl Definer) -> Result<()>
More customizable version of .generate()
.
With this call, one can provide a custom implementation of a Definer
,
which can be useful for mock tests, mainly.
Trait Implementations§
Auto Trait Implementations§
impl<'__, W> RefUnwindSafe for Builder<'__, W>where W: RefUnwindSafe,
impl<'__, W> Send for Builder<'__, W>where W: Send,
impl<'__, W> Sync for Builder<'__, W>where W: Sync,
impl<'__, W> Unpin for Builder<'__, W>where W: Unpin,
impl<'__, W> UnwindSafe for Builder<'__, W>where W: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> FitForCBox for T
impl<T> FitForCBox for T
§type CBoxWrapped = Box_<T>
type CBoxWrapped = Box_<T>
alloc
only.source§impl<T> ManuallyDropMut for T
impl<T> ManuallyDropMut for T
type Ret = ManuallyDrop<T>
fn manually_drop_mut<'__>(&'__ mut self) -> &'__ mut ManuallyDrop<T>
source§impl<T> UpcastAny for Twhere
T: 'static,
impl<T> UpcastAny for Twhere T: 'static,
source§fn upcast_any(&self) -> &(dyn Any + 'static)
fn upcast_any(&self) -> &(dyn Any + 'static)
headers
only.