logo
pub 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

Returns a null externref value.

Returns the corresponding Type for this Value.

Converts the Value into a RawValue.

Converts a RawValue to a Value.

Safety

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.

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.

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.

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.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

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

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.

upcast ref

upcast mut ref

upcast boxed dyn

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more