Enum wasmer_types::Value[][src]

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

impl<T> Value<T> where
    T: WasmValueType
[src]

pub fn null() -> Self[src]

Returns a null externref value.

pub fn ty(&self) -> Type[src]

Returns the corresponding Type for this Value.

pub unsafe fn write_value_to(&self, p: *mut i128)[src]

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

pub unsafe fn read_value_from(store: &dyn Any, p: *const i128, ty: Type) -> Self[src]

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

pub fn i32(&self) -> Option<i32>[src]

Attempt to access the underlying value of this Value, returning None if it is not the correct type.

pub fn unwrap_i32(&self) -> i32[src]

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>[src]

Attempt to access the underlying value of this Value, returning None if it is not the correct type.

pub fn unwrap_i64(&self) -> i64[src]

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>[src]

Attempt to access the underlying value of this Value, returning None if it is not the correct type.

pub fn unwrap_f32(&self) -> f32[src]

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>[src]

Attempt to access the underlying value of this Value, returning None if it is not the correct type.

pub fn unwrap_f64(&self) -> f64[src]

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<ExternRef>[src]

Attempt to access the underlying value of this Value, returning None if it is not the correct type.

pub fn unwrap_externref(&self) -> ExternRef[src]

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<T>>[src]

Attempt to access the underlying value of this Value, returning None if it is not the correct type.

pub fn unwrap_funcref(&self) -> &Option<T>[src]

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>[src]

Attempt to access the underlying value of this Value, returning None if it is not the correct type.

pub fn unwrap_v128(&self) -> u128[src]

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

impl<T: Clone> Clone for Value<T>[src]

fn clone(&self) -> Value<T>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<T> Debug for Value<T> where
    T: WasmValueType
[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<T> From<ExternRef> for Value<T> where
    T: WasmValueType
[src]

fn from(val: ExternRef) -> Self[src]

Performs the conversion.

impl<T> From<f32> for Value<T> where
    T: WasmValueType
[src]

fn from(val: f32) -> Self[src]

Performs the conversion.

impl<T> From<f64> for Value<T> where
    T: WasmValueType
[src]

fn from(val: f64) -> Self[src]

Performs the conversion.

impl<T> From<i32> for Value<T> where
    T: WasmValueType
[src]

fn from(val: i32) -> Self[src]

Performs the conversion.

impl<T> From<i64> for Value<T> where
    T: WasmValueType
[src]

fn from(val: i64) -> Self[src]

Performs the conversion.

impl<T> From<u32> for Value<T> where
    T: WasmValueType
[src]

fn from(val: u32) -> Self[src]

Performs the conversion.

impl<T> From<u64> for Value<T> where
    T: WasmValueType
[src]

fn from(val: u64) -> Self[src]

Performs the conversion.

impl<T: PartialEq> PartialEq<Value<T>> for Value<T>[src]

fn eq(&self, other: &Value<T>) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &Value<T>) -> bool[src]

This method tests for !=.

impl<T> ToString for Value<T> where
    T: WasmValueType
[src]

fn to_string(&self) -> String[src]

Converts the given value to a String. Read more

impl<T> TryFrom<Value<T>> for i32 where
    T: WasmValueType
[src]

type Error = &'static str

The type returned in the event of a conversion error.

fn try_from(value: Value<T>) -> Result<Self, Self::Error>[src]

Performs the conversion.

impl<T> TryFrom<Value<T>> for u32 where
    T: WasmValueType
[src]

type Error = &'static str

The type returned in the event of a conversion error.

fn try_from(value: Value<T>) -> Result<Self, Self::Error>[src]

Performs the conversion.

impl<T> TryFrom<Value<T>> for i64 where
    T: WasmValueType
[src]

type Error = &'static str

The type returned in the event of a conversion error.

fn try_from(value: Value<T>) -> Result<Self, Self::Error>[src]

Performs the conversion.

impl<T> TryFrom<Value<T>> for u64 where
    T: WasmValueType
[src]

type Error = &'static str

The type returned in the event of a conversion error.

fn try_from(value: Value<T>) -> Result<Self, Self::Error>[src]

Performs the conversion.

impl<T> TryFrom<Value<T>> for f32 where
    T: WasmValueType
[src]

type Error = &'static str

The type returned in the event of a conversion error.

fn try_from(value: Value<T>) -> Result<Self, Self::Error>[src]

Performs the conversion.

impl<T> TryFrom<Value<T>> for f64 where
    T: WasmValueType
[src]

type Error = &'static str

The type returned in the event of a conversion error.

fn try_from(value: Value<T>) -> Result<Self, Self::Error>[src]

Performs the conversion.

impl<T> StructuralPartialEq for Value<T>[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> ArchivePointee for T[src]

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.

pub fn pointer_metadata(
    &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
[src]

Converts some archived metadata to the pointer metadata for itself.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Pointee for T

type Metadata = ()

The type for metadata in pointers and references to Self.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.