pub enum Val {
Show 25 variants
    Bool(bool),
    S8(i8),
    U8(u8),
    S16(i16),
    U16(u16),
    S32(i32),
    U32(u32),
    S64(i64),
    U64(u64),
    Float32(f32),
    Float64(f64),
    Char(char),
    String(String),
    List(Vec<Val>),
    Record(Vec<(String, Val)>),
    Tuple(Vec<Val>),
    Variant(String, Option<Box<Val>>),
    Enum(String),
    Option(Option<Box<Val>>),
    Result(Result<Option<Box<Val>>, Option<Box<Val>>>),
    Flags(Vec<String>),
    Resource(ResourceAny),
    Future(FutureAny),
    Stream(StreamAny),
    ErrorContext(ErrorContextAny),
}runtime and component-model only.Expand description
Represents possible runtime values which a component function can either consume or produce
This is a dynamic representation of possible values in the component model.
Note that this is not an efficient representation but is instead intended to
be a flexible and somewhat convenient representation. The most efficient
representation of component model types is to use the bindgen! macro to
generate native Rust types with specialized liftings and lowerings.
This type is used in conjunction with Func::call for example if the
signature of a component is not statically known ahead of time.
§Equality and Val
This type implements both the Rust PartialEq and Eq traits. This type
additionally contains values which are not necessarily easily equated,
however, such as floats (Float32 and Float64) and resources. Equality
does require that two values have the same type, and then these cases are
handled as:
- 
Floats are tested if they are “semantically the same” meaning all NaN values are equal to all other NaN values. Additionally zero values must be exactly the same, so positive zero is not equal to negative zero. The primary use case at this time is fuzzing-related equality which this is sufficient for. 
- 
Resources are tested if their types and indices into the host table are equal. This does not compare the underlying representation so borrows of the same guest resource are not considered equal. This additionally doesn’t go further and test for equality in the guest itself (for example two different heap allocations of Box<u32>can be equal in normal Rust if they contain the same value, but will never be considered equal when compared asVal::Resources).
In general if a strict guarantee about equality is required here it’s recommended to “build your own” as this equality intended for fuzzing Wasmtime may not be suitable for you.
§Component model types and Val
The Val type here does not contain enough information to say what the
component model type of a Val is. This is instead more of an AST of sorts.
For example the Val::Enum only carries information about a single
discriminant, not the entire enumeration or what it’s a discriminant of.
This means that when a Val is passed to Wasmtime, for example as a
function parameter when calling a function or as a return value from an
host-defined imported function, then it must pass a type-check. Instances of
Val are type-checked against what’s required by the component itself.
Variants§
Bool(bool)
S8(i8)
U8(u8)
S16(i16)
U16(u16)
S32(i32)
U32(u32)
S64(i64)
U64(u64)
Float32(f32)
Float64(f64)
Char(char)
String(String)
List(Vec<Val>)
Record(Vec<(String, Val)>)
Tuple(Vec<Val>)
Variant(String, Option<Box<Val>>)
Enum(String)
Option(Option<Box<Val>>)
Result(Result<Option<Box<Val>>, Option<Box<Val>>>)
Flags(Vec<String>)
Resource(ResourceAny)
Future(FutureAny)
Stream(StreamAny)
ErrorContext(ErrorContextAny)
Implementations§
Trait Implementations§
Source§impl WasmValue for Val
Available on crate feature wave only. 
impl WasmValue for Val
wave only.Source§fn unwrap_bool(&self) -> bool
 
fn unwrap_bool(&self) -> bool
Source§fn unwrap_s8(&self) -> i8
 
fn unwrap_s8(&self) -> i8
Source§fn unwrap_s16(&self) -> i16
 
fn unwrap_s16(&self) -> i16
Source§fn unwrap_s32(&self) -> i32
 
fn unwrap_s32(&self) -> i32
Source§fn unwrap_s64(&self) -> i64
 
fn unwrap_s64(&self) -> i64
Source§fn unwrap_u8(&self) -> u8
 
fn unwrap_u8(&self) -> u8
Source§fn unwrap_u16(&self) -> u16
 
fn unwrap_u16(&self) -> u16
Source§fn unwrap_u32(&self) -> u32
 
fn unwrap_u32(&self) -> u32
Source§fn unwrap_u64(&self) -> u64
 
fn unwrap_u64(&self) -> u64
Source§fn unwrap_char(&self) -> char
 
fn unwrap_char(&self) -> char
Source§fn make_string(val: Cow<'_, str>) -> Self
 
fn make_string(val: Cow<'_, str>) -> Self
Source§fn make_list(
    ty: &Self::Type,
    vals: impl IntoIterator<Item = Self>,
) -> Result<Self, WasmValueError>
 
fn make_list( ty: &Self::Type, vals: impl IntoIterator<Item = Self>, ) -> Result<Self, WasmValueError>
Source§fn make_record<'a>(
    ty: &Self::Type,
    fields: impl IntoIterator<Item = (&'a str, Self)>,
) -> Result<Self, WasmValueError>
 
fn make_record<'a>( ty: &Self::Type, fields: impl IntoIterator<Item = (&'a str, Self)>, ) -> Result<Self, WasmValueError>
Source§fn make_tuple(
    ty: &Self::Type,
    vals: impl IntoIterator<Item = Self>,
) -> Result<Self, WasmValueError>
 
fn make_tuple( ty: &Self::Type, vals: impl IntoIterator<Item = Self>, ) -> Result<Self, WasmValueError>
Source§fn make_variant(
    ty: &Self::Type,
    case: &str,
    val: Option<Self>,
) -> Result<Self, WasmValueError>
 
fn make_variant( ty: &Self::Type, case: &str, val: Option<Self>, ) -> Result<Self, WasmValueError>
Source§fn make_enum(ty: &Self::Type, case: &str) -> Result<Self, WasmValueError>
 
fn make_enum(ty: &Self::Type, case: &str) -> Result<Self, WasmValueError>
Source§fn make_option(
    ty: &Self::Type,
    val: Option<Self>,
) -> Result<Self, WasmValueError>
 
fn make_option( ty: &Self::Type, val: Option<Self>, ) -> Result<Self, WasmValueError>
Source§fn make_result(
    ty: &Self::Type,
    val: Result<Option<Self>, Option<Self>>,
) -> Result<Self, WasmValueError>
 
fn make_result( ty: &Self::Type, val: Result<Option<Self>, Option<Self>>, ) -> Result<Self, WasmValueError>
Source§fn make_flags<'a>(
    ty: &Self::Type,
    names: impl IntoIterator<Item = &'a str>,
) -> Result<Self, WasmValueError>
 
fn make_flags<'a>( ty: &Self::Type, names: impl IntoIterator<Item = &'a str>, ) -> Result<Self, WasmValueError>
Source§fn unwrap_f32(&self) -> f32
 
fn unwrap_f32(&self) -> f32
Source§fn unwrap_f64(&self) -> f64
 
fn unwrap_f64(&self) -> f64
Source§fn unwrap_string(&self) -> Cow<'_, str>
 
fn unwrap_string(&self) -> Cow<'_, str>
Source§fn unwrap_list(&self) -> Box<dyn Iterator<Item = Cow<'_, Self>> + '_>
 
fn unwrap_list(&self) -> Box<dyn Iterator<Item = Cow<'_, Self>> + '_>
Source§fn unwrap_record(
    &self,
) -> Box<dyn Iterator<Item = (Cow<'_, str>, Cow<'_, Self>)> + '_>
 
fn unwrap_record( &self, ) -> Box<dyn Iterator<Item = (Cow<'_, str>, Cow<'_, Self>)> + '_>
Source§fn unwrap_tuple(&self) -> Box<dyn Iterator<Item = Cow<'_, Self>> + '_>
 
fn unwrap_tuple(&self) -> Box<dyn Iterator<Item = Cow<'_, Self>> + '_>
Source§fn unwrap_variant(&self) -> (Cow<'_, str>, Option<Cow<'_, Self>>)
 
fn unwrap_variant(&self) -> (Cow<'_, str>, Option<Cow<'_, Self>>)
impl Eq for Val
Auto Trait Implementations§
impl Freeze for Val
impl RefUnwindSafe for Val
impl Send for Val
impl Sync for Val
impl Unpin for Val
impl UnwindSafe for Val
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
    T: Clone,
 
impl<T> CloneToUninit for Twhere
    T: Clone,
§impl<Q, K> Equivalent<K> for Q
 
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
 
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
 
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
 
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
 
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
 
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
 
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more