Trait marine_wasm_backend_traits::imports::Imports
source · 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§
sourcefn new(store: &mut <WB as WasmBackend>::Store) -> Self
fn new(store: &mut <WB as WasmBackend>::Store) -> Self
Creates a new empty object.
sourcefn insert(
&mut self,
store: &impl AsContext<WB>,
module: impl Into<String>,
name: impl Into<String>,
func: <WB as WasmBackend>::HostFunction
) -> Result<(), ImportError>
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.
sourcefn register<S, I>(
&mut self,
store: &impl AsContext<WB>,
name: S,
namespace: I
) -> Result<(), ImportError>
fn register<S, I>( &mut self, store: &impl AsContext<WB>, name: S, namespace: I ) -> Result<(), ImportError>
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.