pub struct RefType { /* private fields */ }
Expand description
Opaque references to data in the Wasm heap or to host data.
§Subtyping and Equality
RefType
does not implement Eq
, because reference 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
RefType::matches
and Ref::matches_ty
methods
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 RefType::eq
method.
Implementations§
Source§impl RefType
impl RefType
Sourcepub const EXTERNREF: Self
Available on crate feature runtime
only.
pub const EXTERNREF: Self
runtime
only.The externref
type, aka (ref null extern)
.
Sourcepub const NULLEXTERNREF: Self
Available on crate feature runtime
only.
pub const NULLEXTERNREF: Self
runtime
only.The nullexternref
type, aka (ref null noextern)
.
Sourcepub const FUNCREF: Self
Available on crate feature runtime
only.
pub const FUNCREF: Self
runtime
only.The funcref
type, aka (ref null func)
.
Sourcepub const NULLFUNCREF: Self
Available on crate feature runtime
only.
pub const NULLFUNCREF: Self
runtime
only.The nullfuncref
type, aka (ref null nofunc)
.
Sourcepub const ANYREF: Self
Available on crate feature runtime
only.
pub const ANYREF: Self
runtime
only.The anyref
type, aka (ref null any)
.
Sourcepub const EQREF: Self
Available on crate feature runtime
only.
pub const EQREF: Self
runtime
only.The eqref
type, aka (ref null eq)
.
Sourcepub const I31REF: Self
Available on crate feature runtime
only.
pub const I31REF: Self
runtime
only.The i31ref
type, aka (ref null i31)
.
Sourcepub const ARRAYREF: Self
Available on crate feature runtime
only.
pub const ARRAYREF: Self
runtime
only.The arrayref
type, aka (ref null array)
.
Sourcepub const STRUCTREF: Self
Available on crate feature runtime
only.
pub const STRUCTREF: Self
runtime
only.The structref
type, aka (ref null struct)
.
Sourcepub const NULLREF: Self
Available on crate feature runtime
only.
pub const NULLREF: Self
runtime
only.The nullref
type, aka (ref null none)
.
Sourcepub const CONTREF: Self
Available on crate feature runtime
only.
pub const CONTREF: Self
runtime
only.The contref
type, aka (ref null cont)
.
Sourcepub const NULLCONTREF: Self
Available on crate feature runtime
only.
pub const NULLCONTREF: Self
runtime
only.The nullcontref
type, aka (ref null nocont)
.
Sourcepub const EXNREF: Self
Available on crate feature runtime
only.
pub const EXNREF: Self
runtime
only.The exnref
type, aka (ref null exn)
.
Sourcepub const NULLEXNREF: Self
Available on crate feature runtime
only.
pub const NULLEXNREF: Self
runtime
only.The nullexnref
type, aka (ref null noexn)
.
Sourcepub fn new(is_nullable: bool, heap_type: HeapType) -> RefType
Available on crate feature runtime
only.
pub fn new(is_nullable: bool, heap_type: HeapType) -> RefType
runtime
only.Construct a new reference type.
Sourcepub fn is_nullable(&self) -> bool
Available on crate feature runtime
only.
pub fn is_nullable(&self) -> bool
runtime
only.Can this type of reference be null?
Sourcepub fn heap_type(&self) -> &HeapType
Available on crate feature runtime
only.
pub fn heap_type(&self) -> &HeapType
runtime
only.The heap type that this is a reference to.
Sourcepub fn matches(&self, other: &RefType) -> bool
Available on crate feature runtime
only.
pub fn matches(&self, other: &RefType) -> bool
runtime
only.Does this reference type match the other?
That is, is this reference type a subtype of the other?
§Panics
Panics if either type is associated with a different engine from the other.
Sourcepub fn eq(a: &RefType, b: &RefType) -> bool
Available on crate feature runtime
only.
pub fn eq(a: &RefType, b: &RefType) -> bool
runtime
only.Is reference type a
precisely equal to reference type b
?
Returns false
even if a
is a subtype of b
or vice versa, if they
are not exactly the same reference type.
§Panics
Panics if either type is associated with a different engine.
Trait Implementations§
Source§impl From<RefType> for StorageType
Available on crate feature runtime
only.
impl From<RefType> for StorageType
runtime
only.Auto Trait Implementations§
impl Freeze for RefType
impl !RefUnwindSafe for RefType
impl Send for RefType
impl Sync for RefType
impl Unpin for RefType
impl !UnwindSafe for RefType
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