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

source

pub fn null() -> InstanceHandle

Creates an “empty” instance handle which internally has a null pointer to an instance.

source

pub fn vmctx(&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_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 all_memories<'a>( &'a mut self ) -> impl ExactSizeIterator<Item = (MemoryIndex, ExportMemory)> + 'a

Get all memories within this instance.

Returns both import and defined memories.

Returns both exported and non-exported memories.

Gives access to the full memories space.

source

pub fn defined_memories<'a>( &'a mut self ) -> impl ExactSizeIterator<Item = ExportMemory> + 'a

Return the memories defined in this instance (not imported).

source

pub fn all_globals<'a>( &'a mut self ) -> impl ExactSizeIterator<Item = (GlobalIndex, ExportGlobal)> + 'a

Get all globals within this instance.

Returns both import and defined globals.

Returns both exported and non-exported globals.

Gives access to the full globals space.

source

pub fn defined_globals<'a>( &'a mut self ) -> impl ExactSizeIterator<Item = (DefinedGlobalIndex, ExportGlobal)> + 'a

Get the globals defined in this instance (not imported).

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.

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where 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 T
where 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 T
where 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.