Struct wasmer_ruby::Wasmer::Global
source · pub struct Global;
Expand description
Represents a WebAssembly global instance.
A global instance is the runtime representation of a global variable. It consists of an individual value and a flag indicating whether it is mutable.
Specification: https://webassembly.github.io/spec/core/exec/runtime.html#global-instances
Example
store = Wasmer::Store.new
global = Wasmer::Global.new store, Wasmer::Value.i32(42), false
assert { global.value == 42 }
type = global.type
assert { type.type == Wasmer::Type::I32 }
assert { type.mutable? == false }
Implementations§
source§impl Global
impl Global
sourcepub fn value(&self, value: Any) -> Any
pub fn value(&self, value: Any) -> Any
Get or set a new value to the global if mutable.
Example
store = Wasmer::Store.new
global = Wasmer::Global.new store, Wasmer::Value.i32(42), true
assert { global.value == 42 }
type = global.type
assert { type.type == Wasmer::Type::I32 }
assert { type.mutable? == true }
global.value = 153
assert { global.value == 153 }
sourcepub fn type(&self) -> GlobalType
pub fn type(&self) -> GlobalType
Returns the global type.
Auto Trait Implementations§
impl RefUnwindSafe for Global
impl Send for Global
impl Sync for Global
impl Unpin for Global
impl UnwindSafe for Global
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more