Struct wasm_wave::value::Type

source ·
pub struct Type(/* private fields */);
Expand description

The WasmType of a Value.

Implementations§

source§

impl Type

source

pub const BOOL: Self = _

source

pub const S8: Self = _

source

pub const S16: Self = _

source

pub const S32: Self = _

source

pub const S64: Self = _

source

pub const U8: Self = _

source

pub const U16: Self = _

source

pub const U32: Self = _

source

pub const U64: Self = _

source

pub const FLOAT32: Self = _

source

pub const FLOAT64: Self = _

source

pub const CHAR: Self = _

source

pub const STRING: Self = _

source

pub fn simple(kind: WasmTypeKind) -> Option<Self>

Returns the simple type of the given kind. Returns None if the kind represents a parameterized type.

source

pub fn list(element_type: impl Into<Self>) -> Self

Returns a list type with the given element type.

source

pub fn record<T: Into<Box<str>>>( field_types: impl IntoIterator<Item = (T, Self)> ) -> Option<Self>

Returns a record type with the given field types. Returns None if fields is empty.

source

pub fn tuple(element_types: impl Into<Box<[Self]>>) -> Option<Self>

Returns a tuple type with the given element types. Returns None if element_types is empty.

source

pub fn variant<T: Into<Box<str>>>( cases: impl IntoIterator<Item = (T, Option<Self>)> ) -> Option<Self>

Returns a variant type with the given case names and optional payloads. Returns None if cases is empty.

source

pub fn enum_ty<T: Into<Box<str>>>( cases: impl IntoIterator<Item = T> ) -> Option<Self>

Returns an enum type with the given case names. Returns None if cases is empty.

source

pub fn option(some: Self) -> Self

Returns an option type with the given “some” type.

source

pub fn result(ok: Option<Self>, err: Option<Self>) -> Self

Returns a result type with the given optional “ok” and “err” payloads.

source

pub fn flags<T: Into<Box<str>>>( flags: impl IntoIterator<Item = T> ) -> Option<Self>

Returns a flags type with the given flag names. Returns None if flags is empty.

source

pub fn from_wasm_type(ty: &impl WasmType) -> Option<Self>

Returns a Type matching the given WasmType. Returns None if the given type is unsupported or otherwise invalid.

Trait Implementations§

source§

impl Clone for Type

source§

fn clone(&self) -> Type

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Type

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for Type

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for Type

source§

fn eq(&self, other: &Type) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl WasmType for Type

source§

fn kind(&self) -> WasmTypeKind

Returns the WasmTypeKind of this type.
source§

fn list_element_type(&self) -> Option<Self>

Returns the list element type or None if self is not a list type. Read more
source§

fn record_fields(&self) -> Box<dyn Iterator<Item = (Cow<'_, str>, Self)> + '_>

Returns an iterator of the record’s field names and Types. The iterator will be empty iff self is not a record type. Read more
source§

fn tuple_element_types(&self) -> Box<dyn Iterator<Item = Self> + '_>

Returns an iterator of the tuple’s field Types. The iterator will be empty iff self is not a tuple type. Read more
source§

fn variant_cases( &self ) -> Box<dyn Iterator<Item = (Cow<'_, str>, Option<Self>)> + '_>

Returns an iterator of the variant’s case names and optional payload Types. The iterator will be empty iff self is not a tuple type. Read more
source§

fn enum_cases(&self) -> Box<dyn Iterator<Item = Cow<'_, str>> + '_>

Returns an iterator of the enum’s case names. The iterator will be empty iff self is not an enum type. Read more
source§

fn option_some_type(&self) -> Option<Self>

Returns the option’s “some” type or None if self is not an option type. Read more
source§

fn result_types(&self) -> Option<(Option<Self>, Option<Self>)>

Returns the result’s optional “ok” and “err” Types or None if self is not a result type. Read more
source§

fn flags_names(&self) -> Box<dyn Iterator<Item = Cow<'_, str>> + '_>

Returns an iterator of the flags’ names. The iterator will be empty iff self is not a flags type. Read more
source§

impl StructuralPartialEq for Type

Auto Trait Implementations§

§

impl Freeze for Type

§

impl RefUnwindSafe for Type

§

impl Send for Type

§

impl Sync for Type

§

impl Unpin for Type

§

impl UnwindSafe for Type

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> IntoAnyhow for T
where T: Display + Debug + Send + Sync + 'static,

source§

fn into_anyhow(self) -> Error

Converts self into an anyhow::Error.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.