pub trait InstanceGlobals {
    type Global: Clone;

    // Required methods
    fn get_global(&mut self, export_name: &str) -> Self::Global;
    fn get_global_value(&mut self, global: &Self::Global) -> Value;
    fn set_global_value(&mut self, global: &Self::Global, value: Value);
}
Expand description

An adapter for a wasm module instance that is focused on getting and setting globals.

Required Associated Types§

source

type Global: Clone

A handle to a global which can be used to get or set a global variable. This is supposed to be a lightweight handle, like an index or an Rc-like smart-pointer, which is cheap to clone.

Required Methods§

source

fn get_global(&mut self, export_name: &str) -> Self::Global

Get a handle to a global by it’s export name.

The requested export is must exist in the exported list, and it should be a mutable global.

source

fn get_global_value(&mut self, global: &Self::Global) -> Value

Get the current value of the global.

source

fn set_global_value(&mut self, global: &Self::Global, value: Value)

Update the current value of the global.

The global behind the handle is guaranteed to be mutable and the value to be the same type as the global.

Implementors§