Struct wasmi::ModuleRef

source ·
pub struct ModuleRef(_);
Expand description

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 occurred 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§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
The resulting type after dereferencing.
Dereferences the value.
Resolve a function. Read more
Resolve a global variable. Read more
Resolve a memory. Read more
Resolve a table. Read more

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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
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.