Module

Trait Module 

Source
pub trait Module<WB: WasmBackend>: Sized {
    // Required methods
    fn new(
        store: &mut <WB as WasmBackend>::Store,
        wasm: &[u8],
    ) -> ModuleCreationResult<Self>;
    fn custom_sections(&self, name: &str) -> &[Vec<u8>];
    fn instantiate<'args>(
        &'args self,
        store: &'args mut <WB as WasmBackend>::Store,
        imports: &'args <WB as WasmBackend>::Imports,
    ) -> BoxFuture<'args, InstantiationResult<<WB as WasmBackend>::Instance>>;
}
Expand description

A handle to compiled wasm module.

Required Methods§

Source

fn new( store: &mut <WB as WasmBackend>::Store, wasm: &[u8], ) -> ModuleCreationResult<Self>

Compiles a wasm bytes into a module and extracts custom sections.

Source

fn custom_sections(&self, name: &str) -> &[Vec<u8>]

Returns custom sections corresponding to name, empty slice if there is no sections.

Source

fn instantiate<'args>( &'args self, store: &'args mut <WB as WasmBackend>::Store, imports: &'args <WB as WasmBackend>::Imports, ) -> BoxFuture<'args, InstantiationResult<<WB as WasmBackend>::Instance>>

Instantiates module by allocating memory, VM state and linking imports with ones from import argument. Does not call _start or _initialize functions.

§Panics:
If the `Store` given is not the same with `Store` used to create `Imports` and this object.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§