logo
pub struct Global { /* private fields */ }
Expand description

Defines a WebAssembly global variable, which stores a single value of the given GlobalType and a flag indicating whether it is mutable or not.

Implementations

Creates a new wasm global variable with the given type and initial value.

Arguments
  • ty - The type of the global variable to be created.

  • init - The initial value of the global variable.

Error

If fail to create the global variable, then an error is returned.

Returns the exported name of this Global.

Notice that this field is meaningful only if this global variable is used as an exported instance.

Returns the name of the module instance from which this Global exports.

Notice that this field is meaningful only if this global variable is used as an exported instance.

Returns the type of this Global.

Returns the current value of this Global.

Sets a new value of this Global.

Notice that only global variables of Var type are allowed to perform this function.

Argument
  • value - The new value of the Global.
Error

If fail to update the value of the global variable, then an error is returned.

Trait Implementations

Formats the value using the given formatter. 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 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.