pub struct InventoryBuilder { /* private fields */ }
Expand description

Produces a Inventory inside your inventory function, start here.

ยงExample

Define an inventory function containing a function, constant, and an extra type. This function can be called from your unit tests and the returned Inventory used to create bindings.

use interoptopus::{Inventory, InventoryBuilder, function, constant, extra_type, pattern, ffi_function, ffi_constant, ffi_type};

// First, define some items our DLL uses or needs.

#[ffi_function]
#[no_mangle]
pub extern "C" fn primitive_void() { }

#[ffi_constant]
pub const MY_CONSTANT: u32 = 123;

#[ffi_type]
#[repr(C)]
pub struct ExtraType<T> {
    x: T
}

// Then list all items for which to generate bindings. Call this function
// from another crate or unit test and feed the `Library` into a backend to
// generate bindings for a specific language.
pub fn my_inventory() -> Inventory {
    InventoryBuilder::new()
        .register(function!(primitive_void))
        .register(constant!(MY_CONSTANT))
        .register(extra_type!(ExtraType<f32>))
        .inventory()
}

Implementationsยง

sourceยง

impl InventoryBuilder

source

pub fn new() -> Self

Start creating a new library.

source

pub fn register(self, s: Symbol) -> Self

Registers a symbol.

Call this with the result of a function, constant, extra_type or pattern macro, see the example above.

source

pub fn inventory(self) -> Inventory

Produce the Inventory.

Trait Implementationsยง

sourceยง

impl Debug for InventoryBuilder

sourceยง

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
sourceยง

impl Default for InventoryBuilder

sourceยง

fn default() -> InventoryBuilder

Returns the โ€œdefault valueโ€ for a type. Read more

Auto Trait Implementationsยง

Blanket Implementationsยง

sourceยง

impl<T> Any for T
where T: 'static + ?Sized,

sourceยง

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
sourceยง

impl<T> Borrow<T> for T
where T: ?Sized,

sourceยง

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
sourceยง

impl<T> BorrowMut<T> for T
where T: ?Sized,

sourceยง

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
sourceยง

impl<T> From<T> for T

sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

sourceยง

impl<T, U> Into<U> for T
where U: From<T>,

sourceยง

fn into(self) -> U

Calls U::from(self).

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

sourceยง

impl<T, U> TryFrom<U> for T
where U: Into<T>,

ยง

type Error = Infallible

The type returned in the event of a conversion error.
sourceยง

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
sourceยง

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

ยง

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

The type returned in the event of a conversion error.
sourceยง

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.