pub struct ArrayType { /* private fields */ }Expand description
The type of a WebAssembly array.
WebAssembly arrays are dynamically-sized, but not resizable. They contain
either unpacked Vals or packed 8-/16-bit integers.
§Subtyping and Equality
ArrayType 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 ArrayType::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 ArrayType::eq method.
Implementations§
Source§impl ArrayType
impl ArrayType
Sourcepub fn new(engine: &Engine, field_type: FieldType) -> Self
Available on crate feature runtime only.
pub fn new(engine: &Engine, field_type: FieldType) -> Self
runtime only.Construct a new ArrayType with the given field type’s mutability and
storage type.
The new ArrayType will be final and without a supertype.
The result will be associated with the given engine, and attempts to use it with other engines will panic (for example, checking whether it is a subtype of another array type that is associated with a different engine).
§Panics
Panics if the given field type is not associated with the given engine.
Sourcepub fn with_finality_and_supertype(
engine: &Engine,
finality: Finality,
supertype: Option<&Self>,
field_type: FieldType,
) -> Result<Self>
Available on crate feature runtime only.
pub fn with_finality_and_supertype( engine: &Engine, finality: Finality, supertype: Option<&Self>, field_type: FieldType, ) -> Result<Self>
runtime only.Construct a new StructType with the given finality, supertype, and
fields.
The result will be associated with the given engine, and attempts to use it with other engines will panic (for example, checking whether it is a subtype of another struct type that is associated with a different engine).
Returns an error if the supertype is final, or if this type does not match the supertype.
§Panics
Panics if the given field type is not associated with the given engine.
Sourcepub fn engine(&self) -> &Engine
Available on crate feature runtime only.
pub fn engine(&self) -> &Engine
runtime only.Get the engine that this array type is associated with.
Sourcepub fn finality(&self) -> Finality
Available on crate feature runtime only.
pub fn finality(&self) -> Finality
runtime only.Get the finality of this array type.
Sourcepub fn supertype(&self) -> Option<Self>
Available on crate feature runtime only.
pub fn supertype(&self) -> Option<Self>
runtime only.Get the supertype of this array type, if any.
Sourcepub fn field_type(&self) -> FieldType
Available on crate feature runtime only.
pub fn field_type(&self) -> FieldType
runtime only.Get this array’s underlying field type.
The field type contains information about both this array type’s mutability and the storage type used for its elements.
Sourcepub fn mutability(&self) -> Mutability
Available on crate feature runtime only.
pub fn mutability(&self) -> Mutability
runtime only.Get this array type’s mutability and whether its instances’ elements can be updated or not.
This is a convenience method providing a short-hand for
my_array_type.field_type().mutability().
Sourcepub fn element_type(&self) -> StorageType
Available on crate feature runtime only.
pub fn element_type(&self) -> StorageType
runtime only.Get the storage type used for this array type’s elements.
This is a convenience method providing a short-hand for
my_array_type.field_type().element_type().
Sourcepub fn matches(&self, other: &ArrayType) -> bool
Available on crate feature runtime only.
pub fn matches(&self, other: &ArrayType) -> bool
runtime only.Does this array type match the other array type?
That is, is this function type a subtype of the other array type?
§Panics
Panics if either type is associated with a different engine from the other.
Sourcepub fn eq(a: &ArrayType, b: &ArrayType) -> bool
Available on crate feature runtime only.
pub fn eq(a: &ArrayType, b: &ArrayType) -> bool
runtime only.Is array type a precisely equal to array type b?
Returns false even if a is a subtype of b or vice versa, if they
are not exactly the same array type.
§Panics
Panics if either type is associated with a different engine from the other.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ArrayType
impl !RefUnwindSafe for ArrayType
impl Send for ArrayType
impl Sync for ArrayType
impl Unpin for ArrayType
impl !UnwindSafe for ArrayType
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