pub struct Builder<'__, W> { /* private fields */ }
Available on crate feature
headers
only.Implementations
sourceimpl<'__, 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_PKG_NAME")?.replace("-", "_").to_ascii_uppercase())
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. * * * *******************************************/
sourceimpl<'__> 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()?
sourceimpl Builder<'_, WhereTo>
impl Builder<'_, WhereTo>
sourcepub fn generate_with_definer(self, definer: impl Definer) -> Result<()>
pub fn generate_with_definer(self, definer: 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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more