pub struct Global { /* private fields */ }
Expand description
A Global instance
Implementations§
Source§impl Global
impl Global
Sourcepub fn new(global_type: GlobalType) -> Self
pub fn new(global_type: GlobalType) -> Self
Create a new, zero bit-pattern initialized global from a GlobalType
.
Sourcepub fn ty(&self) -> &GlobalType
pub fn ty(&self) -> &GlobalType
Get the type of the global.
Sourcepub fn vmglobal(&self) -> NonNull<VMGlobalDefinition>
pub fn vmglobal(&self) -> NonNull<VMGlobalDefinition>
Get a pointer to the underlying definition used by the generated code.
Sourcepub fn get<T: WasmValueType>(&self, store: &dyn Any) -> Value<T>
pub fn get<T: WasmValueType>(&self, store: &dyn Any) -> Value<T>
Get a value from the global.
Sourcepub unsafe fn set<T: WasmValueType>(
&self,
val: Value<T>,
) -> Result<(), GlobalError>
pub unsafe fn set<T: WasmValueType>( &self, val: Value<T>, ) -> Result<(), GlobalError>
Set a value for the global.
§Safety
The caller should check that the val
comes from the same store as this global.
Sourcepub unsafe fn set_unchecked<T: WasmValueType>(
&self,
val: Value<T>,
) -> Result<(), GlobalError>
pub unsafe fn set_unchecked<T: WasmValueType>( &self, val: Value<T>, ) -> Result<(), GlobalError>
Set a value from the global (unchecked)
§Safety
The caller should check that the val
comes from the same store as this global.
The caller should also ensure that this global is synchronized. Otherwise, use
set
instead.
Trait Implementations§
impl Send for Global
§Safety
This is safe to send between threads because there is no-thread specific logic.
TODO: look into other reasons that make something not Send
impl Sync for Global
§Safety
This is safe to share between threads because it uses a Mutex
internally.
Auto Trait Implementations§
impl !Freeze for Global
impl !RefUnwindSafe for Global
impl Unpin for Global
impl !UnwindSafe for Global
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§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