Trait wasm_wave::wasm::WasmType

source ·
pub trait WasmType: Clone + Sized {
    // Required method
    fn kind(&self) -> WasmTypeKind;

    // Provided methods
    fn list_element_type(&self) -> Option<Self> { ... }
    fn record_fields(
        &self
    ) -> Box<dyn Iterator<Item = (Cow<'_, str>, Self)> + '_> { ... }
    fn tuple_element_types(&self) -> Box<dyn Iterator<Item = Self> + '_> { ... }
    fn variant_cases(
        &self
    ) -> Box<dyn Iterator<Item = (Cow<'_, str>, Option<Self>)> + '_> { ... }
    fn enum_cases(&self) -> Box<dyn Iterator<Item = Cow<'_, str>> + '_> { ... }
    fn option_some_type(&self) -> Option<Self> { ... }
    fn result_types(&self) -> Option<(Option<Self>, Option<Self>)> { ... }
    fn flags_names(&self) -> Box<dyn Iterator<Item = Cow<'_, str>> + '_> { ... }
}
Expand description

The WasmType trait may be implemented to represent types to be (de)serialized with WAVE, notably value::Type and wasmtime::component::Type.

The Self-returning methods should be called only for corresponding WasmTypeKinds.

Required Methods§

source

fn kind(&self) -> WasmTypeKind

Returns the WasmTypeKind of this type.

Provided Methods§

source

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

Returns the list element type or None if self is not a list type.

§Panics

Panics if the type is not implemented (the trait default).

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.

§Panics

Panics if the type is not implemented (the trait default).

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.

§Panics

Panics if the type is not implemented (the trait default).

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.

§Panics

Panics if the type is not implemented (the trait default).

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.

§Panics

Panics if the type is not implemented (the trait default).

source

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

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

§Panics

Panics if the type is not implemented (the trait default).

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.

§Panics

Panics if the type is not implemented (the trait default).

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.

§Panics

Panics if the type is not implemented (the trait default).

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl WasmType for Type

source§

fn kind(&self) -> WasmTypeKind

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

impl WasmType for ValType

source§

fn kind(&self) -> WasmTypeKind

source§

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

Implementors§

source§

impl WasmType for wasm_wave::value::Type