[][src]Struct wasmer_runtime::Instance

pub struct Instance {
    pub module: Arc<ModuleInner>,
    // some fields omitted

An instantiated WebAssembly module.

An Instance represents a WebAssembly module that has been instantiated with an ImportObject and is ready to be called.


module: Arc<ModuleInner>

Reference to the module used to instantiate this instance.


impl Instance[src]

pub fn load<T>(
    loader: T
) -> Result<<T as Loader>::Instance, <T as Loader>::Error> where
    T: Loader

Load an Instance using the given loader.

pub fn func<Args, Rets>(
    name: &str
) -> Result<Func<Args, Rets, Wasm>, ResolveError> where
    Args: WasmTypeList,
    Rets: WasmTypeList

Through generic magic and the awe-inspiring power of traits, we bring you...


A Func allows you to call functions exported from wasm with near zero overhead.


let func: Func<(i32, i32)> = instance.func("foo")?;

func.call(42, 43);

pub fn resolve_func(&self, name: &str) -> Result<usize, ResolveError>[src]

Resolve a function by name.

pub fn dyn_func(&self, name: &str) -> Result<DynFunc, ResolveError>[src]

This returns the representation of a function that can be called safely.



pub fn call(
    name: &str,
    params: &[Value]
) -> Result<Vec<Value>, CallError>

Call an exported WebAssembly function given the export name. Pass arguments by wrapping each one in the Value enum. The returned values are also each wrapped in a Value.


This returns CallResult<Vec<Value>> in order to support the future multi-value returns WebAssembly feature.


// ...
let results = instance.call("foo", &[Value::I32(42)])?;
// ...

pub fn context(&self) -> &Ctx[src]

Returns an immutable reference to the Ctx used by this Instance.

pub fn context_mut(&mut self) -> &mut Ctx[src]

Returns a mutable reference to the Ctx used by this Instance.

pub fn exports(&self) -> ExportIter[src]

Returns an iterator over all of the items exported from this instance.

pub fn module(&self) -> Module[src]

The module used to instantiate this Instance.

pub fn get_internal(&self, field: &InternalField) -> u64[src]

Get the value of an internal field

pub fn set_internal(&mut self, field: &InternalField, value: u64)[src]

Set the value of an internal field.

Trait Implementations

impl LikeNamespace for Instance[src]

Auto Trait Implementations

impl !RefUnwindSafe for Instance

impl Send for Instance

impl !Sync for Instance

impl Unpin for Instance

impl !UnwindSafe for Instance

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

impl<T> Same<T> for T

type Output = T

Should always be Self

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

type Error = Infallible

The type returned in the event of a conversion error.

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.