[][src]Struct wasmer::Instance

pub struct Instance {
    pub exports: Exports,
    // some fields omitted

A WebAssembly Instance is a stateful, executable instance of a WebAssembly Module.

Instance objects contain all the exported WebAssembly functions, memories, tables and globals that allow interacting with WebAssembly.

Spec: https://webassembly.github.io/spec/core/exec/runtime.html#module-instances


exports: Exports

The exports for an instance.


impl Instance[src]

pub fn new(
    module: &Module,
    resolver: &dyn Resolver
) -> Result<Self, InstantiationError>

Creates a new Instance from a WebAssembly Module and a set of imports resolved by the Resolver.

The resolver can be anything that implements the Resolver trait, so you can plug custom resolution for the imports, if you wish not to use ImportObject.

The ImportObject is the easiest way to provide imports to the instance.

let store = Store::default();
let module = Module::new(&store, "(module)")?;
let imports = imports!{
  "host" => {
    "var" => Global::new(&store, Value::I32(2))
let instance = Instance::new(&module, &imports)?;


The function can return InstantiationErrors.

Those are, as defined by the spec:

  • Link errors that happen when plugging the imports into the instance
  • Runtime errors that happen when running the module start function.

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

Gets the Module associated with this instance.

pub fn store(&self) -> &Store[src]

Returns the Store where the Instance belongs.

Trait Implementations

impl Clone for Instance[src]

impl Debug for Instance[src]

Auto Trait Implementations

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> Instrument for T[src]

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

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> ToOwned for T where
    T: Clone

type Owned = T

The resulting type after obtaining ownership.

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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,