Enum wasmer_wasix::syscalls::Value
pub(crate) enum Value {
I32(i32),
I64(i64),
F32(f32),
F64(f64),
ExternRef(Option<ExternRef>),
FuncRef(Option<Function>),
V128(u128),
}
Expand description
WebAssembly computations manipulate values of basic value types:
- Integers (32 or 64 bit width)
- Floating-point (32 or 64 bit width)
- Vectors (128 bits, with 32 or 64 bit lanes)
Spec: https://webassembly.github.io/spec/core/exec/runtime.html#values
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(Option<ExternRef>)
An externref
value which can hold opaque data to the wasm instance itself.
FuncRef(Option<Function>)
A first-class reference to a WebAssembly function.
V128(u128)
A 128-bit number
Implementations§
§impl Value
impl Value
pub fn ty(&self) -> Type
pub fn ty(&self) -> Type
Returns the corresponding [Type
] for this Value
.
pub fn as_raw(&self, store: &impl AsStoreRef) -> RawValue
pub fn as_raw(&self, store: &impl AsStoreRef) -> RawValue
Converts the Value
into a RawValue
.
pub unsafe fn from_raw(
store: &mut impl AsStoreMut,
ty: Type,
raw: RawValue,
) -> Value
pub unsafe fn from_raw( store: &mut impl AsStoreMut, ty: Type, raw: RawValue, ) -> Value
Converts a RawValue
to a Value
.
§Safety
pub fn is_from_store(&self, store: &impl AsStoreRef) -> bool
pub fn is_from_store(&self, store: &impl AsStoreRef) -> bool
Checks whether a value can be used with the given context.
Primitive (i32
, i64
, etc) and null funcref/externref values are not
tied to a context and can be freely shared between contexts.
Externref and funcref values are tied to a context and can only be used with that context.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.
pub fn externref(&self) -> Option<&Option<ExternRef>>
pub fn externref(&self) -> Option<&Option<ExternRef>>
Attempt to access the underlying value of this Value
, returning
None
if it is not the correct type.
pub fn unwrap_externref(&self) -> &Option<ExternRef>
pub fn unwrap_externref(&self) -> &Option<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.
pub fn funcref(&self) -> Option<&Option<Function>>
pub fn funcref(&self) -> Option<&Option<Function>>
Attempt to access the underlying value of this Value
, returning
None
if it is not the correct type.
pub fn unwrap_funcref(&self) -> &Option<Function>
pub fn unwrap_funcref(&self) -> &Option<Function>
Returns the underlying value of this Value
, panicking if it’s the
wrong type.
§Panics
Panics if self
is not of the right type.
pub 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.
pub 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§
Auto Trait Implementations§
impl Freeze for Value
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnwindSafe for Value
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more