pub struct ModuleInstance(/* private fields */);
Expand description
An instanciated WebAssembly module
Backed by an Rc, so cloning is cheap
See https://webassembly.github.io/spec/core/exec/runtime.html#module-instances
Implementations§
Source§impl ModuleInstance
impl ModuleInstance
Sourcepub fn id(&self) -> ModuleInstanceAddr
pub fn id(&self) -> ModuleInstanceAddr
Get the module instance’s address
Sourcepub fn instantiate(
store: &mut Store,
module: Module,
imports: Option<Imports>,
) -> Result<Self>
pub fn instantiate( store: &mut Store, module: Module, imports: Option<Imports>, ) -> Result<Self>
Instantiate the module in the given store
See https://webassembly.github.io/spec/core/exec/modules.html#exec-instantiation
Sourcepub fn export_addr(&self, name: &str) -> Option<ExternVal>
pub fn export_addr(&self, name: &str) -> Option<ExternVal>
Get a export by name
Sourcepub fn exported_func_untyped(
&self,
store: &Store,
name: &str,
) -> Result<FuncHandle>
pub fn exported_func_untyped( &self, store: &Store, name: &str, ) -> Result<FuncHandle>
Get an exported function by name
Sourcepub fn exported_func<P, R>(
&self,
store: &Store,
name: &str,
) -> Result<FuncHandleTyped<P, R>>where
P: IntoWasmValueTuple,
R: FromWasmValueTuple,
pub fn exported_func<P, R>(
&self,
store: &Store,
name: &str,
) -> Result<FuncHandleTyped<P, R>>where
P: IntoWasmValueTuple,
R: FromWasmValueTuple,
Get a typed exported function by name
Sourcepub fn exported_memory<'a>(
&self,
store: &'a mut Store,
name: &str,
) -> Result<MemoryRef<'a>>
pub fn exported_memory<'a>( &self, store: &'a mut Store, name: &str, ) -> Result<MemoryRef<'a>>
Get an exported memory by name
Sourcepub fn exported_memory_mut<'a>(
&self,
store: &'a mut Store,
name: &str,
) -> Result<MemoryRefMut<'a>>
pub fn exported_memory_mut<'a>( &self, store: &'a mut Store, name: &str, ) -> Result<MemoryRefMut<'a>>
Get an exported memory by name
Sourcepub fn memory<'a>(
&self,
store: &'a Store,
addr: MemAddr,
) -> Result<MemoryRef<'a>>
pub fn memory<'a>( &self, store: &'a Store, addr: MemAddr, ) -> Result<MemoryRef<'a>>
Get a memory by address
Sourcepub fn memory_mut<'a>(
&self,
store: &'a mut Store,
addr: MemAddr,
) -> Result<MemoryRefMut<'a>>
pub fn memory_mut<'a>( &self, store: &'a mut Store, addr: MemAddr, ) -> Result<MemoryRefMut<'a>>
Get a memory by address (mutable)
Sourcepub fn start_func(&self, store: &Store) -> Result<Option<FuncHandle>>
pub fn start_func(&self, store: &Store) -> Result<Option<FuncHandle>>
Get the start function of the module
Returns None if the module has no start function If no start function is specified, also checks for a _start function in the exports
See https://webassembly.github.io/spec/core/syntax/modules.html#start-function
Trait Implementations§
Source§impl Clone for ModuleInstance
impl Clone for ModuleInstance
Source§fn clone(&self) -> ModuleInstance
fn clone(&self) -> ModuleInstance
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more