pub enum HeapType {
Extern,
Func,
Concrete(FuncType),
NoFunc,
}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.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for HeapType
impl !UnwindSafe for HeapType
impl Freeze for HeapType
impl Send for HeapType
impl Sync for HeapType
impl Unpin for HeapType
impl UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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