pub struct RefType(/* private fields */);
Expand description
A reference type.
The reference types proposal first introduced externref
and
funcref
.
The function references proposal introduced typed function references.
The GC proposal introduces heap types: any, eq, i31, struct, array, nofunc, noextern, none.
Implementations§
Source§impl RefType
impl RefType
Sourcepub const FUNCREF: Self = _
pub const FUNCREF: Self = _
A nullable untyped function reference aka (ref null func)
aka
funcref
aka anyfunc
.
Sourcepub const EXTERNREF: Self = _
pub const EXTERNREF: Self = _
A nullable reference to an extern object aka (ref null extern)
aka
externref
.
Sourcepub const NULLEXTERNREF: Self = _
pub const NULLEXTERNREF: Self = _
A nullable reference to a noextern object aka (ref null noextern)
aka
nullexternref
.
Sourcepub const NULLFUNCREF: Self = _
pub const NULLFUNCREF: Self = _
A nullable reference to a nofunc object aka (ref null nofunc)
aka
nullfuncref
.
Sourcepub const STRUCTREF: Self = _
pub const STRUCTREF: Self = _
A nullable reference to a struct aka (ref null struct)
aka
structref
.
Sourcepub const ARRAYREF: Self = _
pub const ARRAYREF: Self = _
A nullable reference to an array aka (ref null array)
aka arrayref
.
Sourcepub const I31REF: Self = _
pub const I31REF: Self = _
A nullable reference to an i31 object aka (ref null i31)
aka i31ref
.
Sourcepub const EXNREF: Self = _
pub const EXNREF: Self = _
A nullable reference to an exception object aka (ref null exn)
aka
exnref
.
Sourcepub const NULLEXNREF: Self = _
pub const NULLEXNREF: Self = _
A nullable reference to a noexn object aka (ref null noexn)
aka
nullexnref
.
Sourcepub const CONTREF: Self = _
pub const CONTREF: Self = _
A nullable reference to a cont object aka (ref null cont)
aka
contref
.
Sourcepub const NULLCONTREF: Self = _
pub const NULLCONTREF: Self = _
A nullable reference to a nocont object aka (ref null nocont)
aka
nullcontref
.
Sourcepub fn concrete(nullable: bool, index: PackedIndex) -> Self
pub fn concrete(nullable: bool, index: PackedIndex) -> Self
Create a reference to a concrete Wasm-defined type at the given index.
Returns None
when the type index is beyond this crate’s
implementation limits and therefore is not representable.
Sourcepub fn new(nullable: bool, heap_type: HeapType) -> Option<Self>
pub fn new(nullable: bool, heap_type: HeapType) -> Option<Self>
Create a new RefType
.
Returns None
when the heap type’s type index (if any) is beyond this
crate’s implementation limits and therefore is not representable.
Sourcepub fn difference(a: RefType, b: RefType) -> RefType
pub fn difference(a: RefType, b: RefType) -> RefType
Compute the type difference between the two given ref types.
Sourcepub const fn is_concrete_type_ref(&self) -> bool
pub const fn is_concrete_type_ref(&self) -> bool
Is this a reference to an concrete type?
Sourcepub fn type_index(&self) -> Option<PackedIndex>
pub fn type_index(&self) -> Option<PackedIndex>
If this is a reference to a concrete Wasm-defined type, get its type index.
Sourcepub const fn is_func_ref(&self) -> bool
pub const fn is_func_ref(&self) -> bool
Is this the abstract untyped function reference type aka (ref null func)
aka funcref
aka anyfunc
?
Sourcepub const fn is_extern_ref(&self) -> bool
pub const fn is_extern_ref(&self) -> bool
Is this the abstract external reference type aka (ref null extern)
aka externref
?
Sourcepub const fn is_array_ref(&self) -> bool
pub const fn is_array_ref(&self) -> bool
Is this the abstract untyped array reference type aka (ref null array)
aka arrayref
?
Sourcepub const fn is_struct_ref(&self) -> bool
pub const fn is_struct_ref(&self) -> bool
Is this the abstract untyped struct reference type aka (ref null struct)
aka structref
?
Sourcepub const fn is_cont_ref(&self) -> bool
pub const fn is_cont_ref(&self) -> bool
Is this the abstract untyped cont reference type aka (ref null cont)
aka contref
?
Sourcepub const fn is_nullable(&self) -> bool
pub const fn is_nullable(&self) -> bool
Is this ref type nullable?
Sourcepub const fn as_non_null(&self) -> Self
pub const fn as_non_null(&self) -> Self
Get the non-nullable version of this ref type.
Get the shared version of this ref type as long as it is abstract.
Trait Implementations§
Source§impl<'a> FromReader<'a> for RefType
impl<'a> FromReader<'a> for RefType
Source§fn from_reader(reader: &mut BinaryReader<'a>) -> Result<Self>
fn from_reader(reader: &mut BinaryReader<'a>) -> Result<Self>
Self
from the provided binary reader, returning an
error if it is unable to do so.