Trait marine_wasm_backend_traits::instance::Instance

source ·
pub trait Instance<WB: WasmBackend>: Clone {
    // Required methods
    fn export_iter<'a>(
        &'a self,
        store: <WB as WasmBackend>::ContextMut<'a>
    ) -> Box<dyn Iterator<Item = (&'a str, Export<WB>)> + 'a>;
    fn get_nth_memory(
        &self,
        store: &mut impl AsContextMut<WB>,
        memory_index: u32
    ) -> Option<<WB as WasmBackend>::Memory>;
    fn get_memory(
        &self,
        store: &mut impl AsContextMut<WB>,
        memory_name: &str
    ) -> ResolveResult<<WB as WasmBackend>::Memory>;
    fn get_function(
        &self,
        store: &mut impl AsContextMut<WB>,
        name: &str
    ) -> ResolveResult<<WB as WasmBackend>::ExportFunction>;
}
Expand description

A handle to an instantiated Wasm module. Cloning is cheap.

Required Methods§

source

fn export_iter<'a>( &'a self, store: <WB as WasmBackend>::ContextMut<'a> ) -> Box<dyn Iterator<Item = (&'a str, Export<WB>)> + 'a>

Returns an Iterator to all exports of this instance.

source

fn get_nth_memory( &self, store: &mut impl AsContextMut<WB>, memory_index: u32 ) -> Option<<WB as WasmBackend>::Memory>

Returns nth exported memory, None if there is no nth memory. No guaranties is known for memory order, but almost always a module has only one memory, hence the only valid value for memory_index is 0.

source

fn get_memory( &self, store: &mut impl AsContextMut<WB>, memory_name: &str ) -> ResolveResult<<WB as WasmBackend>::Memory>

Returns a memory export with given name.

§Errors:
Returns an error if there is no export with such name, or it is not a memory.
source

fn get_function( &self, store: &mut impl AsContextMut<WB>, name: &str ) -> ResolveResult<<WB as WasmBackend>::ExportFunction>

Returns an exported function with the given name.

§Errors:
Returns an error if there is no export with such name, or it is not a function.

Object Safety§

This trait is not object safe.

Implementors§