Struct tinywasm::ModuleInstance
source · pub struct ModuleInstance(/* private fields */);
Expand description
An instanciated WebAssembly module
Backed by an Arc, 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 exported_func_by_name(
&self,
store: &Store,
name: &str
) -> Result<FuncHandle>
pub fn exported_func_by_name( &self, store: &Store, name: &str ) -> Result<FuncHandle>
Get an exported function by name
sourcepub fn typed_func<P, R>(
&self,
store: &Store,
name: &str
) -> Result<FuncHandleTyped<P, R>>where
P: IntoWasmValueTuple,
R: FromWasmValueTuple,
pub fn typed_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 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 (which is not part of the spec, but used by llvm)
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
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl RefUnwindSafe for ModuleInstance
impl Send for ModuleInstance
impl Sync for ModuleInstance
impl Unpin for ModuleInstance
impl UnwindSafe for ModuleInstance
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more