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 unsafe fn from_vmctx(vmctx: *mut VMContext) -> Self
pub unsafe fn from_vmctx(vmctx: *mut VMContext) -> Self
Create a new InstanceHandle
pointing at the instance
pointed to by the given VMContext
pointer.
§Safety
This is unsafe because it doesn’t work on just any VMContext
, it must
be a VMContext
allocated as part of an Instance
.
sourcepub fn vmctx_ptr(&self) -> *mut VMContext
pub fn vmctx_ptr(&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_memory(&mut self, index: DefinedMemoryIndex) -> *mut Memory
pub fn get_defined_memory(&mut self, index: DefinedMemoryIndex) -> *mut Memory
Get a memory defined locally within this module.
sourcepub unsafe fn table_index(
&mut self,
table: &VMTableDefinition,
) -> DefinedTableIndex
pub unsafe fn table_index( &mut self, table: &VMTableDefinition, ) -> DefinedTableIndex
Return the table index for the given VMTableDefinition
in 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 creqtaed 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.
Trait Implementations§
source§impl Hash for InstanceHandle
impl Hash for InstanceHandle
source§impl PartialEq for InstanceHandle
impl PartialEq for InstanceHandle
source§fn eq(&self, other: &InstanceHandle) -> bool
fn eq(&self, other: &InstanceHandle) -> bool
self
and other
values to be equal, and is used
by ==
.impl Eq for InstanceHandle
impl Send for InstanceHandle
impl StructuralPartialEq for InstanceHandle
impl Sync for InstanceHandle
Auto Trait Implementations§
impl Freeze for InstanceHandle
impl !RefUnwindSafe for InstanceHandle
impl Unpin for InstanceHandle
impl !UnwindSafe for InstanceHandle
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
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.