Struct wasmtime_runtime::InstanceHandle
source · pub struct InstanceHandle { /* private fields */ }
Expand description
A handle holding an Instance
of a WebAssembly module.
Implementations§
source§impl InstanceHandle
impl InstanceHandle
sourcepub fn null() -> InstanceHandle
pub fn null() -> InstanceHandle
Creates an “empty” instance handle which internally has a null pointer to an instance.
sourcepub fn vmctx(&self) -> *mut VMContext
pub fn vmctx(&self) -> *mut VMContext
Return a raw pointer to the vmctx used by compiled wasm code.
sourcepub fn get_exported_func(&mut self, export: FuncIndex) -> ExportFunction
pub fn get_exported_func(&mut self, export: FuncIndex) -> ExportFunction
Lookup a function by index.
sourcepub fn get_exported_global(&mut self, export: GlobalIndex) -> ExportGlobal
pub fn get_exported_global(&mut self, export: GlobalIndex) -> ExportGlobal
Lookup a global by index.
sourcepub fn get_exported_memory(&mut self, export: MemoryIndex) -> ExportMemory
pub fn get_exported_memory(&mut self, export: MemoryIndex) -> ExportMemory
Lookup a memory by index.
sourcepub fn get_exported_table(&mut self, export: TableIndex) -> ExportTable
pub fn get_exported_table(&mut self, export: TableIndex) -> ExportTable
Lookup a table by index.
sourcepub fn get_export_by_index(&mut self, export: EntityIndex) -> Export
pub fn get_export_by_index(&mut self, export: EntityIndex) -> Export
Lookup an item with the given index.
sourcepub fn exports(&self) -> Iter<'_, String, EntityIndex>
pub fn exports(&self) -> Iter<'_, String, EntityIndex>
Return an iterator over the exports of this instance.
Specifically, it provides access to the key-value pairs, where the keys
are export names, and the values are export declarations which can be
resolved lookup_by_declaration
.
sourcepub fn host_state(&self) -> &dyn Any
pub fn host_state(&self) -> &dyn Any
Return a reference to the custom state attached to this instance.
sourcepub fn get_defined_table(&mut self, index: DefinedTableIndex) -> *mut Table
pub fn get_defined_table(&mut self, index: DefinedTableIndex) -> *mut Table
Get a table defined locally within this module.
sourcepub fn get_defined_table_with_lazy_init(
&mut self,
index: DefinedTableIndex,
range: impl Iterator<Item = u32>
) -> *mut Table
pub fn get_defined_table_with_lazy_init( &mut self, index: DefinedTableIndex, range: impl Iterator<Item = u32> ) -> *mut Table
Get a table defined locally within this module, lazily initializing the given range first.
sourcepub unsafe fn set_store(&mut self, store: *mut dyn Store)
pub unsafe fn set_store(&mut self, store: *mut dyn Store)
Configure the *mut dyn Store
internal pointer after-the-fact.
This is provided for the original Store
itself to configure the first
self-pointer after the original Box
has been initialized.
sourcepub unsafe fn clone(&self) -> InstanceHandle
pub unsafe fn clone(&self) -> InstanceHandle
Returns a clone of this instance.
This is unsafe because the returned handle here is just a cheap clone of the internals, there’s no lifetime tracking around its validity. You’ll need to ensure that the returned handles all go out of scope at the same time.
sourcepub fn initialize(
&mut self,
module: &Module,
is_bulk_memory: bool
) -> Result<()>
pub fn initialize( &mut self, module: &Module, is_bulk_memory: bool ) -> Result<()>
Performs post-initialization of an instance after its handle has been created and registered with a store.
Failure of this function means that the instance still must persist within the store since failure may indicate partial failure, or some state could be referenced by other instances.
sourcepub fn wasm_fault(&self, addr: usize) -> Option<WasmFault>
pub fn wasm_fault(&self, addr: usize) -> Option<WasmFault>
Attempts to convert from the host addr
specified to a WebAssembly
based address recorded in WasmFault
.
This method will check all linear memories that this instance contains
to see if any of them contain addr
. If one does then Some
is
returned with metadata about the wasm fault. Otherwise None
is
returned and addr
doesn’t belong to this instance.