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

Returns a null externref value.

Returns the corresponding Type for this Value.

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

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

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

Returns the underlying value of this Value, panicking if it’s the wrong type.

Panics

Panics if self is not of the right type.

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

Returns the underlying value of this Value, panicking if it’s the wrong type.

Panics

Panics if self is not of the right type.

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

Returns the underlying value of this Value, panicking if it’s the wrong type.

Panics

Panics if self is not of the right type.

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

Returns the underlying value of this Value, panicking if it’s the wrong type.

Panics

Panics if self is not of the right type.

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

Returns the underlying value of this Value, panicking if it’s the wrong type.

Panics

Panics if self is not of the right type.

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

Returns the underlying value of this Value, panicking if it’s the wrong type.

Panics

Panics if self is not of the right type.

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

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

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

This method tests for !=.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

The archived version of the pointer metadata for this type.

Converts some archived metadata to the pointer metadata for itself.

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Deserializes using the given deserializer

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type for metadata in pointers and references to Self.

The resulting type after obtaining ownership.

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

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.