Struct wiggle::wasmtime_crate::ArrayType
source · 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 Val
s 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) -> ArrayType
pub fn new(engine: &Engine, field_type: FieldType) -> ArrayType
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<&ArrayType>,
field_type: FieldType
) -> Result<ArrayType, Error>
pub fn with_finality_and_supertype( engine: &Engine, finality: Finality, supertype: Option<&ArrayType>, field_type: FieldType ) -> Result<ArrayType, Error>
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 field_type(&self) -> FieldType
pub fn field_type(&self) -> FieldType
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
pub fn mutability(&self) -> Mutability
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
pub fn element_type(&self) -> StorageType
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()
.