pub struct InstanceHandle { /* private fields */ }
Expand description

A handle holding an Instance of a WebAssembly module.

Implementations§

source§

impl InstanceHandle

source

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.

source

pub fn vmctx(&self) -> &VMContext

Return a reference to the vmctx used by compiled wasm code.

source

pub fn vmctx_ptr(&self) -> *mut VMContext

Return a raw pointer to the vmctx used by compiled wasm code.

source

pub fn module(&self) -> &Arc<Module>

Return a reference to a module.

source

pub fn get_exported_func(&mut self, export: FuncIndex) -> ExportFunction

Lookup a function by index.

source

pub fn get_exported_global(&mut self, export: GlobalIndex) -> ExportGlobal

Lookup a global by index.

source

pub fn get_exported_memory(&mut self, export: MemoryIndex) -> ExportMemory

Lookup a memory by index.

source

pub fn get_exported_table(&mut self, export: TableIndex) -> ExportTable

Lookup a table by index.

source

pub fn get_export_by_index(&mut self, export: EntityIndex) -> Export

Lookup an item with the given index.

source

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.

source

pub fn host_state(&self) -> &dyn Any

Return a reference to the custom state attached to this instance.

source

pub fn get_defined_memory(&mut self, index: DefinedMemoryIndex) -> *mut Memory

Get a memory defined locally within this module.

source

pub unsafe fn table_index( &mut self, table: &VMTableDefinition ) -> DefinedTableIndex

Return the table index for the given VMTableDefinition in this instance.

source

pub fn get_defined_table(&mut self, index: DefinedTableIndex) -> *mut Table

Get a table defined locally within this module.

source

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.

source

pub fn store(&self) -> *mut dyn Store

Returns the Store pointer that was stored on creation

source

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.

source

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.

source

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.

source

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

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq<InstanceHandle> for InstanceHandle

source§

fn eq(&self, other: &InstanceHandle) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for InstanceHandle

source§

impl Send for InstanceHandle

source§

impl StructuralEq for InstanceHandle

source§

impl StructuralPartialEq for InstanceHandle

source§

impl Sync for InstanceHandle

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.