pub struct Type(/* private fields */);
Implementations§
source§impl Type
impl Type
pub const BOOL: Self = _
pub const S8: Self = _
pub const S16: Self = _
pub const S32: Self = _
pub const S64: Self = _
pub const U8: Self = _
pub const U16: Self = _
pub const U32: Self = _
pub const U64: Self = _
pub const FLOAT32: Self = _
pub const FLOAT64: Self = _
pub const CHAR: Self = _
pub const STRING: Self = _
sourcepub fn simple(kind: WasmTypeKind) -> Option<Self>
pub fn simple(kind: WasmTypeKind) -> Option<Self>
Returns the simple type of the given kind
. Returns None if the kind
represents a parameterized type.
sourcepub fn list(element_type: impl Into<Self>) -> Self
pub fn list(element_type: impl Into<Self>) -> Self
Returns a list type with the given element type.
sourcepub fn record<T: Into<Box<str>>>(
field_types: impl IntoIterator<Item = (T, Self)>
) -> Option<Self>
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.
sourcepub fn tuple(element_types: impl Into<Box<[Self]>>) -> Option<Self>
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.
sourcepub fn variant<T: Into<Box<str>>>(
cases: impl IntoIterator<Item = (T, Option<Self>)>
) -> Option<Self>
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.
sourcepub fn enum_ty<T: Into<Box<str>>>(
cases: impl IntoIterator<Item = T>
) -> Option<Self>
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.
sourcepub fn result(ok: Option<Self>, err: Option<Self>) -> Self
pub fn result(ok: Option<Self>, err: Option<Self>) -> Self
Returns a result type with the given optional “ok” and “err” payloads.
Trait Implementations§
source§impl PartialEq for Type
impl PartialEq for Type
source§impl WasmType for Type
impl WasmType for Type
source§fn kind(&self) -> WasmTypeKind
fn kind(&self) -> WasmTypeKind
Returns the
WasmTypeKind
of this type.source§fn list_element_type(&self) -> Option<Self>
fn list_element_type(&self) -> Option<Self>
source§fn record_fields(&self) -> Box<dyn Iterator<Item = (Cow<'_, str>, Self)> + '_>
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 moresource§fn tuple_element_types(&self) -> Box<dyn Iterator<Item = Self> + '_>
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 moresource§fn variant_cases(
&self
) -> Box<dyn Iterator<Item = (Cow<'_, str>, Option<Self>)> + '_>
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 moresource§fn enum_cases(&self) -> Box<dyn Iterator<Item = Cow<'_, str>> + '_>
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 moresource§fn option_some_type(&self) -> Option<Self>
fn option_some_type(&self) -> Option<Self>
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> 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
Mutably borrows from an owned value. Read more
source§impl<T> IntoAnyhow for T
impl<T> IntoAnyhow for T
source§fn into_anyhow(self) -> Error
fn into_anyhow(self) -> Error
Converts
self
into an anyhow::Error
.