pub trait Imports<WB: WasmBackend>: Clone {
    // Required methods
    fn new(store: &mut <WB as WasmBackend>::Store) -> Self;
    fn insert(
        &mut self,
        store: &impl AsContext<WB>,
        module: impl Into<String>,
        name: impl Into<String>,
        func: <WB as WasmBackend>::HostFunction
    ) -> Result<(), ImportError>;
    fn register<S, I>(
        &mut self,
        store: &impl AsContext<WB>,
        name: S,
        namespace: I
    ) -> Result<(), ImportError>
       where S: Into<String>,
             I: IntoIterator<Item = (String, <WB as WasmBackend>::HostFunction)>;
}
Expand description

A “Linker” object, that is used to match functions with module imports during instantiation. Cloning is a cheap operation for this object. All clones refer to the same data in store.

Required Methods§

source

fn new(store: &mut <WB as WasmBackend>::Store) -> Self

Creates a new empty object.

source

fn insert( &mut self, store: &impl AsContext<WB>, module: impl Into<String>, name: impl Into<String>, func: <WB as WasmBackend>::HostFunction ) -> Result<(), ImportError>

Inserts a function with name name to the namespace module.

§Errors:
An error returned if such combination of `module` and `name` already has an associated function.
source

fn register<S, I>( &mut self, store: &impl AsContext<WB>, name: S, namespace: I ) -> Result<(), ImportError>
where S: Into<String>, I: IntoIterator<Item = (String, <WB as WasmBackend>::HostFunction)>,

Inserts several named functions to the same namespace module at once, an equivalent to multiple calls of insert.

§Errors:
An error returned if such combination of `module` and `name` already has an associated function.

Object Safety§

This trait is not object safe.

Implementors§