Skip to main content

WasmInstance

Trait WasmInstance 

Source
pub trait WasmInstance: Send {
    // Required methods
    fn call_with_allocation_stats(
        &mut self,
        method: &str,
        data: &[u8],
    ) -> (Result<Vec<u8>, Error>, Option<AllocationStats>);
    fn get_global_const(&mut self, name: &str) -> Result<Option<Value>, Error>;

    // Provided methods
    fn call(&mut self, method: &str, data: &[u8]) -> Result<Vec<u8>, Error> { ... }
    fn call_export(
        &mut self,
        method: &str,
        data: &[u8],
    ) -> Result<Vec<u8>, Error> { ... }
}
Expand description

A trait that defines an abstract wasm module instance.

This can be implemented by an execution engine.

Required Methods§

Source

fn call_with_allocation_stats( &mut self, method: &str, data: &[u8], ) -> (Result<Vec<u8>, Error>, Option<AllocationStats>)

Call a method on this WASM instance.

Before execution, instance is reset.

Returns the encoded result on success.

Source

fn get_global_const(&mut self, name: &str) -> Result<Option<Value>, Error>

Get the value from a global with the given name.

This method is only suitable for getting immutable globals.

Provided Methods§

Source

fn call(&mut self, method: &str, data: &[u8]) -> Result<Vec<u8>, Error>

Call a method on this WASM instance.

Before execution, instance is reset.

Returns the encoded result on success.

Source

fn call_export(&mut self, method: &str, data: &[u8]) -> Result<Vec<u8>, Error>

Call an exported method on this WASM instance.

Before execution, instance is reset.

Returns the encoded result on success.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§