Struct wasmedge_sdk::Global
source · 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§
source§impl Global
impl Global
sourcepub fn new(ty: GlobalType, init: Val) -> WasmEdgeResult<Self>
pub fn new(ty: GlobalType, init: Val) -> WasmEdgeResult<Self>
Creates a new wasm Global instance with the given type and initial value.
Arguments
-
ty
- The type of the Global instance to be created. -
init
- The initial value of the Global instance.
Error
- If fail to create the Global instance, then WasmEdgeError::Global(GlobalError::Create)(crate::error::GlobalError) is returned.
sourcepub fn name(&self) -> Option<&str>
pub fn name(&self) -> Option<&str>
Returns the exported name of this Global instance.
Notice that this field is meaningful only if this Global instance is used as an exported instance.
sourcepub fn mod_name(&self) -> Option<&str>
pub fn mod_name(&self) -> Option<&str>
Returns the name of the module instance from which this Global instance exports.
Notice that this field is meaningful only if this Global instance is used as an exported instance.
sourcepub fn ty(&self) -> &GlobalType
pub fn ty(&self) -> &GlobalType
Returns a reference to the type of this Global instance.
sourcepub fn set_value(&mut self, val: Val) -> WasmEdgeResult<()>
pub fn set_value(&mut self, val: Val) -> WasmEdgeResult<()>
Trait Implementations§
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§
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