Struct wasmtime::Global [−][src]
pub struct Global { /* fields omitted */ }
A WebAssembly global
value which can be read and written to.
A global
in WebAssembly is sort of like a global variable within an
Instance
. The global.get
and global.set
instructions will modify and read global values in a wasm module. Globals
can either be imported or exported from wasm modules.
If you’re familiar with Rust already you can think of a Global
as a sort
of Rc<Cell<Val>>
, more or less.
Global
and Clone
Globals are internally reference counted so you can clone
a Global
. The
cloning process only performs a shallow clone, so two cloned Global
instances are equivalent in their functionality.
Implementations
impl Global
[src]
impl Global
[src]pub fn new(store: &Store, ty: GlobalType, val: Val) -> Result<Global>
[src][−]
Creates a new WebAssembly global
value with the provide type ty
and
initial value val
.
The store
argument provided is used as a general global cache for
information, and otherwise the ty
and val
arguments are used to
initialize the global.
Errors
Returns an error if the ty
provided does not match the type of the
value val
.
pub fn ty(&self) -> GlobalType
[src][−]
Returns the underlying type of this global
.
pub fn val_type(&self) -> ValType
[src][−]
Returns the value type of this global
.
pub fn mutability(&self) -> Mutability
[src][−]
Returns the underlying mutability of this global
.
pub fn get(&self) -> Val
[src][−]
Returns the current Val
of this global.