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>

Access all globals. This is a non-standard API so it’s unlikely to be portable to other engines.

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

Invoke exported function by a name using recycled stacks.

Errors

Same as invoke_export.

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

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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.