Enum wasmer_types::Value
source · [−]pub enum Value<T> {
I32(i32),
I64(i64),
F32(f32),
F64(f64),
ExternRef(ExternRef),
FuncRef(Option<T>),
V128(u128),
}
Expand description
Possible runtime values that a WebAssembly module can either consume or produce.
Variants
I32(i32)
A 32-bit integer.
In Wasm integers are sign-agnostic, i.e. this can either be signed or unsigned.
I64(i64)
A 64-bit integer.
In Wasm integers are sign-agnostic, i.e. this can either be signed or unsigned.
F32(f32)
A 32-bit float.
F64(f64)
A 64-bit float.
ExternRef(ExternRef)
An externref
value which can hold opaque data to the wasm instance itself.
Note that this is a nullable value as well.
FuncRef(Option<T>)
A first-class reference to a WebAssembly function.
V128(u128)
A 128-bit number
Implementations
sourceimpl<T> Value<T> where
T: WasmValueType,
impl<T> Value<T> where
T: WasmValueType,
sourcepub unsafe fn write_value_to(&self, p: *mut i128)
pub unsafe fn write_value_to(&self, p: *mut i128)
Writes it’s value to a given pointer
Safety
p
must be:
- Sufficiently aligned for the Rust equivalent of the type in
self
- Non-null and pointing to valid, mutable memory
sourcepub unsafe fn read_value_from(store: &dyn Any, p: *const i128, ty: Type) -> Self
pub unsafe fn read_value_from(store: &dyn Any, p: *const i128, ty: Type) -> Self
Gets a Value
given a pointer and a Type
Safety
p
must be:
- Properly aligned to the specified
ty
’s Rust equivalent - Non-null and pointing to valid memory
sourcepub fn i32(&self) -> Option<i32>
pub fn i32(&self) -> Option<i32>
Attempt to access the underlying value of this Value
, returning
None
if it is not the correct type.
sourcepub fn unwrap_i32(&self) -> i32
pub fn unwrap_i32(&self) -> i32
Returns the underlying value of this Value
, panicking if it’s the
wrong type.
Panics
Panics if self
is not of the right type.
sourcepub fn i64(&self) -> Option<i64>
pub fn i64(&self) -> Option<i64>
Attempt to access the underlying value of this Value
, returning
None
if it is not the correct type.
sourcepub fn unwrap_i64(&self) -> i64
pub fn unwrap_i64(&self) -> i64
Returns the underlying value of this Value
, panicking if it’s the
wrong type.
Panics
Panics if self
is not of the right type.
sourcepub fn f32(&self) -> Option<f32>
pub fn f32(&self) -> Option<f32>
Attempt to access the underlying value of this Value
, returning
None
if it is not the correct type.
sourcepub fn unwrap_f32(&self) -> f32
pub fn unwrap_f32(&self) -> f32
Returns the underlying value of this Value
, panicking if it’s the
wrong type.
Panics
Panics if self
is not of the right type.
sourcepub fn f64(&self) -> Option<f64>
pub fn f64(&self) -> Option<f64>
Attempt to access the underlying value of this Value
, returning
None
if it is not the correct type.
sourcepub fn unwrap_f64(&self) -> f64
pub fn unwrap_f64(&self) -> f64
Returns the underlying value of this Value
, panicking if it’s the
wrong type.
Panics
Panics if self
is not of the right type.
sourcepub fn externref(&self) -> Option<ExternRef>
pub fn externref(&self) -> Option<ExternRef>
Attempt to access the underlying value of this Value
, returning
None
if it is not the correct type.
sourcepub fn unwrap_externref(&self) -> ExternRef
pub fn unwrap_externref(&self) -> ExternRef
Returns the underlying value of this Value
, panicking if it’s the
wrong type.
Panics
Panics if self
is not of the right type.
sourcepub fn funcref(&self) -> Option<&Option<T>>
pub fn funcref(&self) -> Option<&Option<T>>
Attempt to access the underlying value of this Value
, returning
None
if it is not the correct type.
sourcepub fn unwrap_funcref(&self) -> &Option<T>
pub fn unwrap_funcref(&self) -> &Option<T>
Returns the underlying value of this Value
, panicking if it’s the
wrong type.
Panics
Panics if self
is not of the right type.
sourcepub fn v128(&self) -> Option<u128>
pub fn v128(&self) -> Option<u128>
Attempt to access the underlying value of this Value
, returning
None
if it is not the correct type.
sourcepub fn unwrap_v128(&self) -> u128
pub fn unwrap_v128(&self) -> u128
Returns the underlying value of this Value
, panicking if it’s the
wrong type.
Panics
Panics if self
is not of the right type.
Trait Implementations
sourceimpl<T> Debug for Value<T> where
T: WasmValueType,
impl<T> Debug for Value<T> where
T: WasmValueType,
sourceimpl<T> From<ExternRef> for Value<T> where
T: WasmValueType,
impl<T> From<ExternRef> for Value<T> where
T: WasmValueType,
sourceimpl<T> From<f32> for Value<T> where
T: WasmValueType,
impl<T> From<f32> for Value<T> where
T: WasmValueType,
sourceimpl<T> From<f64> for Value<T> where
T: WasmValueType,
impl<T> From<f64> for Value<T> where
T: WasmValueType,
sourceimpl<T> From<i32> for Value<T> where
T: WasmValueType,
impl<T> From<i32> for Value<T> where
T: WasmValueType,
sourceimpl<T> From<i64> for Value<T> where
T: WasmValueType,
impl<T> From<i64> for Value<T> where
T: WasmValueType,
sourceimpl<T> From<u32> for Value<T> where
T: WasmValueType,
impl<T> From<u32> for Value<T> where
T: WasmValueType,
sourceimpl<T> From<u64> for Value<T> where
T: WasmValueType,
impl<T> From<u64> for Value<T> where
T: WasmValueType,
sourceimpl<T> ToString for Value<T> where
T: WasmValueType,
impl<T> ToString for Value<T> where
T: WasmValueType,
sourceimpl<T> TryFrom<Value<T>> for i32 where
T: WasmValueType,
impl<T> TryFrom<Value<T>> for i32 where
T: WasmValueType,
sourceimpl<T> TryFrom<Value<T>> for u32 where
T: WasmValueType,
impl<T> TryFrom<Value<T>> for u32 where
T: WasmValueType,
sourceimpl<T> TryFrom<Value<T>> for i64 where
T: WasmValueType,
impl<T> TryFrom<Value<T>> for i64 where
T: WasmValueType,
sourceimpl<T> TryFrom<Value<T>> for u64 where
T: WasmValueType,
impl<T> TryFrom<Value<T>> for u64 where
T: WasmValueType,
sourceimpl<T> TryFrom<Value<T>> for f32 where
T: WasmValueType,
impl<T> TryFrom<Value<T>> for f32 where
T: WasmValueType,
sourceimpl<T> TryFrom<Value<T>> for f64 where
T: WasmValueType,
impl<T> TryFrom<Value<T>> for f64 where
T: WasmValueType,
impl<T> StructuralPartialEq for Value<T>
Auto Trait Implementations
impl<T> !RefUnwindSafe for Value<T>
impl<T> !Send for Value<T>
impl<T> !Sync for Value<T>
impl<T> Unpin for Value<T> where
T: Unpin,
impl<T> !UnwindSafe for Value<T>
Blanket Implementations
sourceimpl<T> ArchivePointee for T
impl<T> ArchivePointee for T
type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
sourcefn 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