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(
        &self,
        store: &mut <WB as WasmBackend>::Store,
        imports: &<WB as WasmBackend>::Imports
    ) -> 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( &self, store: &mut <WB as WasmBackend>::Store, imports: &<WB as WasmBackend>::Imports ) -> 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.

Object Safety§

This trait is not object safe.

Implementors§