[][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

Fields

exports: Exports

The exports for an instance.

Implementations

impl Instance[src]

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

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)?;

Errors

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

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
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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>,