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 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 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.