[][src]Struct safer_ffi::headers::Builder

pub struct Builder<'__, W> { /* fields omitted */ }
This is supported on feature="headers" only.

Implementations

impl<'__, W> Builder<'__, W>[src]

pub fn with_guard(self, guard: &'__ str) -> Self[src]

This is supported on feature="headers" only.

Sets up the name of the ifndef guard of the header file.

It defaults to:

This example is not tested
format!("__RUST_{}__", env::var("CARGO_PKG_NAME")?.to_ascii_uppercase())

pub fn with_banner(self, banner: &'__ str) -> Self[src]

This is supported on feature="headers" only.

Sets up the banner of the generated C header file.

It defaults to:

This example is not tested
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.        *
 *                                         *
 *******************************************/

impl<'__> Builder<'__, WhereTo>[src]

pub fn to_file(self, filename: impl AsRef<Path>) -> Result<Builder<'__, File>>[src]

This is supported on feature="headers" only.

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()?

pub fn to_writer<W>(self, out: W) -> Builder<'__, W> where
    W: Write
[src]

This is supported on feature="headers" only.

Specify the Write "stream" where the headers will be written to.

Example

// Display the headers to the standard output
// (may need the `--nocapture` flag when running the tests)
::safer_ffi::headers::builder()
    .to_writer(::std::io::stdout())
    .generate()?

impl<'__, W: Write> Builder<'__, W>[src]

pub fn generate(self) -> Result<()>[src]

This is supported on feature="headers" only.

Generate the C header file.

impl<'_> Builder<'_, WhereTo>[src]

pub fn generate_with_definer(self, definer: impl Definer) -> Result<()>[src]

This is supported on feature="headers" only.

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

impl<'__, W: Default> Default for Builder<'__, W>[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ManuallyDropMut for T

type Ret = ManuallyDrop<T>

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.