Instance

Trait 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.

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§