pub struct Builder<'__, W> { /* private fields */ }
Available on crate feature headers only.

Implementations

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

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.        *
 *                                         *
 *******************************************/

Sets the Language of the generated headers.

It defaults to Language::C.

Sets prefix for generated functions, structs & enums

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.

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

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

Generate the C header file.

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

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Applies the Compat adapter by value. Read more
Applies the Compat adapter by shared reference. Read more
Applies the Compat adapter by mutable reference. Read more
Available on crate feature alloc only.

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Available on crate feature headers only.