[][src]Enum wasmer_types::Value

pub enum Value<T> {
    I32(i32),
    I64(i64),
    F32(f32),
    F64(f64),
    ExternRef(ExternRef),
    FuncRef(T),
    V128(u128),
}

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(T)

A first-class reference to a WebAssembly function.

V128(u128)

A 128-bit number

Implementations

impl<T> Value<T>[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(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 funcref(&self) -> 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) -> &T

Notable traits for &'_ mut I

impl<'_, I> Iterator for &'_ mut I where
    I: Iterator + ?Sized
type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
    F: Unpin + Future + ?Sized
type Output = <F as Future>::Output;
[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.

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.

This will return Some for both the ExternRef and FuncRef types.

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.

Trait Implementations

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

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

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

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

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

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

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

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

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

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

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

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

impl<T> TryFrom<Value<T>> for i32[src]

type Error = &'static str

The type returned in the event of a conversion error.

impl<T> TryFrom<Value<T>> for u32[src]

type Error = &'static str

The type returned in the event of a conversion error.

impl<T> TryFrom<Value<T>> for i64[src]

type Error = &'static str

The type returned in the event of a conversion error.

impl<T> TryFrom<Value<T>> for u64[src]

type Error = &'static str

The type returned in the event of a conversion error.

impl<T> TryFrom<Value<T>> for f32[src]

type Error = &'static str

The type returned in the event of a conversion error.

impl<T> TryFrom<Value<T>> for f64[src]

type Error = &'static str

The type returned in the event of a conversion error.

Auto Trait Implementations

impl<T> !RefUnwindSafe for Value<T>[src]

impl<T> !Send for Value<T>[src]

impl<T> !Sync for Value<T>[src]

impl<T> Unpin for Value<T> where
    T: Unpin
[src]

impl<T> !UnwindSafe for Value<T>[src]

Blanket Implementations

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

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

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

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

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

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

type Owned = T

The resulting type after obtaining ownership.

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.

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.