Struct wasmi::ModuleRef[][src]

pub struct ModuleRef(_);

Reference to a ModuleInstance.

This reference has a reference-counting semantics.

All ModuleInstance have strong references to it's components (i.e. globals, memories, funcs, tables), however, this components have weak references to it's containing module. This might be a problem at execution time.

So if have to make sure that all modules which might be needed at execution time should be retained.

Methods from Deref<Target = ModuleInstance>

Invoke exported function by a name.

This function finds exported function by a name, and calls it with provided arguments and external state.

Errors

Returns Err if:

  • there are no export with a given name or this export is not a function,
  • given arguments doesn't match to function signature,
  • trap occured at the execution time,

Examples

Invoke a function that takes two numbers and returns sum of them.

assert_eq!(
    instance.invoke_export(
        "add",
        &[RuntimeValue::I32(5), RuntimeValue::I32(3)],
        &mut NopExternals,
    ).expect("failed to execute export"),
    Some(RuntimeValue::I32(8)),
);

Find export by a name.

Returns None if there is no export with such name.

Trait Implementations

impl Clone for ModuleRef
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for ModuleRef
[src]

Formats the value using the given formatter. Read more

impl Deref for ModuleRef
[src]

The resulting type after dereferencing.

Dereferences the value.

impl ModuleImportResolver for ModuleRef
[src]

Resolve a function. Read more

Resolve a global variable. Read more

Resolve a memory. Read more

Resolve a table. Read more

Auto Trait Implementations

impl !Send for ModuleRef

impl !Sync for ModuleRef