pub struct Global { /* private fields */ }
Expand description
A Global instance
Implementations
sourceimpl 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
sourceimpl MemoryUsage for Global
impl MemoryUsage for Global
sourcefn size_of_val(&self, visited: &mut dyn MemoryUsageTracker) -> usize
fn size_of_val(&self, visited: &mut dyn MemoryUsageTracker) -> usize
Returns the size of the referenced value in bytes. Read more
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
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.
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<F, W, T, D> Deserialize<With<T, W>, D> for F where
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
impl<F, W, T, D> Deserialize<With<T, W>, D> for F where
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
Deserializes using the given deserializer
sourceimpl<T> Upcastable for T where
T: 'static + Any + Send + Sync,
impl<T> Upcastable for T where
T: 'static + Any + Send + Sync,
sourcefn upcast_any_ref(&self) -> &(dyn Any + 'static)
fn upcast_any_ref(&self) -> &(dyn Any + 'static)
upcast ref
sourcefn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
upcast mut ref