Enum wasmtime::Val

source ·
pub enum Val {
    I32(i32),
    I64(i64),
    F32(u32),
    F64(u64),
    V128(u128),
    FuncRef(Option<Func>),
    ExternRef(Option<ExternRef>),
}
Expand description

Possible runtime values that a WebAssembly module can either consume or produce.

Variants

I32(i32)

A 32-bit integer

I64(i64)

A 64-bit integer

F32(u32)

A 32-bit float.

Note that the raw bits of the float are stored here, and you can use f32::from_bits to create an f32 value.

F64(u64)

A 64-bit float.

Note that the raw bits of the float are stored here, and you can use f64::from_bits to create an f64 value.

V128(u128)

A 128-bit number

FuncRef(Option<Func>)

A first-class reference to a WebAssembly function.

FuncRef(None) is the null function reference, created by ref.null func in Wasm.

ExternRef(Option<ExternRef>)

An externref value which can hold opaque data to the Wasm instance itself.

ExternRef(None) is the null external reference, created by ref.null extern in Wasm.

Implementations

Returns a null externref value.

Returns the corresponding ValType for this Val.

Convenience method to convert this Val into a ValRaw.

Unsafety

This method is unsafe for the reasons that ExternRef::to_raw and Func::to_raw are unsafe.

Convenience method to convert a ValRaw into a Val.

Unsafety

This method is unsafe for the reasons that ExternRef::from_raw and Func::from_raw are unsafe. Additionaly there’s no guarantee otherwise that raw should have the type ty specified.

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

Returns the underlying value of this Val, 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 Val, returning None if it is not the correct type.

Returns the underlying value of this Val, 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 Val, returning None if it is not the correct type.

Returns the underlying value of this Val, 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 Val, returning None if it is not the correct type.

Returns the underlying value of this Val, 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 Val, returning None if it is not the correct type.

Returns the underlying value of this Val, 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 Val, returning None if it is not the correct type.

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

Panics

Panics if self is not of the right type.

Attempt to access the underlying externref value of this Val.

If this is not an externref, then None is returned.

If this is a null externref, then Some(None) is returned.

If this is a non-null externref, then Some(Some(..)) is returned.

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

If this is a null externref, then None is returned.

If this is a non-null externref, then Some(..) is returned.

Panics

Panics if self is not a (nullable) externref.

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.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

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 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
Should always be 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.