pub enum HeapType {
Extern,
Func,
Concrete(FuncType),
NoFunc,
Any,
I31,
None,
}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, structs, and
arrays).
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_extern(&self) -> bool
Available on crate feature runtime only.
pub fn is_extern(&self) -> bool
runtime only.Is this the abstract extern heap type?
Sourcepub fn is_func(&self) -> bool
Available on crate feature runtime only.
pub fn is_func(&self) -> bool
runtime only.Is this the abstract func heap type?
Sourcepub fn is_no_func(&self) -> bool
Available on crate feature runtime only.
pub fn is_no_func(&self) -> bool
runtime only.Is this the abstract nofunc heap type?
Sourcepub fn is_any(&self) -> bool
Available on crate feature runtime only.
pub fn is_any(&self) -> bool
runtime only.Is this the abstract any heap type?
Sourcepub fn is_i31(&self) -> bool
Available on crate feature runtime only.
pub fn is_i31(&self) -> bool
runtime only.Is this the abstract i31 heap type?
Sourcepub fn is_none(&self) -> bool
Available on crate feature runtime only.
pub fn is_none(&self) -> bool
runtime only.Is this the abstract none heap type?
Sourcepub fn is_abstract(&self) -> bool
Available on crate feature runtime only.
pub fn is_abstract(&self) -> bool
runtime only.Is this an abstract type?
Types that are not abstract are concrete, user-defined types.
Sourcepub fn is_concrete(&self) -> bool
Available on crate feature runtime only.
pub fn is_concrete(&self) -> bool
runtime only.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>
Available on crate feature runtime only.
pub fn as_concrete(&self) -> Option<&FuncType>
runtime only.Get the underlying concrete, user-defined type, if any.
Returns None for abstract types.
Sourcepub fn unwrap_concrete(&self) -> &FuncType
Available on crate feature runtime only.
pub fn unwrap_concrete(&self) -> &FuncType
runtime only.Get the underlying concrete, user-defined type, panicking if this heap type is not concrete.
Sourcepub fn top(&self, engine: &Engine) -> HeapType
Available on crate feature runtime only.
pub fn top(&self, engine: &Engine) -> HeapType
runtime only.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.
Sourcepub fn matches(&self, other: &HeapType) -> bool
Available on crate feature runtime only.
pub fn matches(&self, other: &HeapType) -> bool
runtime only.Does this heap type match the other heap type?
That is, is this heap type a subtype of the other?
§Panics
Panics if either type is associated with a different engine from the other.
Sourcepub fn eq(a: &HeapType, b: &HeapType) -> bool
Available on crate feature runtime only.
pub fn eq(a: &HeapType, b: &HeapType) -> bool
runtime only.Is heap type a precisely equal to heap type b?
Returns false even if a is a subtype of b or vice versa, if they
are not exactly the same heap type.
§Panics
Panics if either type is associated with a different engine from the other.
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