pub enum HeapType {
Extern,
Func,
Concrete(FuncType),
NoFunc,
Any,
I31,
None,
}
runtime
only.Expand description
The heap types that can Wasm can have references to.
§Subtyping and Equality
HeapType
does not implement Eq
, because heap types have a subtyping
relationship, and so 99.99% of the time you actually want to check whether
one type matches (i.e. is a subtype of) another type. You can use the
HeapType::matches
method to perform these types of checks. If, however,
you are in that 0.01% scenario where you need to check precise equality
between types, you can use the HeapType::eq
method.
Variants§
Extern
The extern
heap type represents external host data.
Func
The func
heap type represents a reference to any kind of function.
This is the top type for the function references type hierarchy, and is therefore a supertype of every function reference.
Concrete(FuncType)
The concrete heap type represents a reference to a function of a specific, concrete type.
This is a subtype of func
and a supertype of nofunc
.
NoFunc
The nofunc
heap type represents the null function reference.
This is the bottom type for the function references type hierarchy, and
therefore nofunc
is a subtype of all function reference types.
Any
The abstract any
heap type represents all internal Wasm data.
This is the top type of the internal type hierarchy, and is therefore a
supertype of all internal types (such as i31
, struct
s, and
array
s).
I31
The i31
heap type represents unboxed 31-bit integers.
None
The abstract none
heap type represents the null internal reference.
This is the bottom type for the internal type hierarchy, and therefore
none
is a subtype of internal types.
Implementations§
Source§impl HeapType
impl HeapType
Sourcepub fn is_no_func(&self) -> bool
pub fn is_no_func(&self) -> bool
Is this the abstract nofunc
heap type?
Sourcepub fn is_abstract(&self) -> bool
pub fn is_abstract(&self) -> bool
Is this an abstract type?
Types that are not abstract are concrete, user-defined types.
Sourcepub fn is_concrete(&self) -> bool
pub fn is_concrete(&self) -> bool
Is this a concrete, user-defined heap type?
Types that are not concrete, user-defined types are abstract types.
Sourcepub fn as_concrete(&self) -> Option<&FuncType>
pub fn as_concrete(&self) -> Option<&FuncType>
Get the underlying concrete, user-defined type, if any.
Returns None
for abstract types.
Sourcepub fn unwrap_concrete(&self) -> &FuncType
pub fn unwrap_concrete(&self) -> &FuncType
Get the underlying concrete, user-defined type, panicking if this heap type is not concrete.
Sourcepub fn top(&self, engine: &Engine) -> HeapType
pub fn top(&self, engine: &Engine) -> HeapType
Get the top type of this heap type’s type hierarchy.
The returned heap type is a supertype of all types in this heap type’s type hierarchy.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for HeapType
impl !RefUnwindSafe for HeapType
impl Send for HeapType
impl Sync for HeapType
impl Unpin for HeapType
impl !UnwindSafe for HeapType
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,
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