pub enum HeapType {
Extern,
Func,
Concrete(FuncType),
NoFunc,
}
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.
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.