Struct wasmer_runtime_fl::Instance[][src]

pub struct Instance {
    pub module: Arc<ModuleInner>,
    pub exports: Exports,
    pub import_object: ImportObject,
    // some fields omitted
}
Expand description

An instantiated WebAssembly module.

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

Fields

module: Arc<ModuleInner>

Reference to the module used to instantiate this instance.

exports: Exports

The exports of this instance.

import_object: ImportObject

Import object of the Instance.

Implementations

Load an Instance using the given loader.

👎 Deprecated since 0.17.0:

Please use instance.exports.get(name) instead

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

“Func”

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

Usage:

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

func.call(42, 43);

Resolve a function by name.

👎 Deprecated since 0.17.0:

Please use instance.exports.get(name) instead

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

Usage:

instance
    .dyn_func("foo")?
    .call(&[])?;

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.

Note:

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

Consider using the more explicit Exports::get with [DynFunc::call`] instead. For example:

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

Usage:

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

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

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

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

The module used to instantiate this Instance.

Get the value of an internal field

Set the value of an internal field.

Trait Implementations

Gets an export by name.

Gets all exports in the namespace.

Maybe insert an Export by name into the namespace.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.