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 F32: Self
pub const F64: 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 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 Eq for Type
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.