pub struct Datatype {
pub scalar: ScalarType,
pub size: u64,
pub byteorder: ByteOrder,
pub shape: Vec<u64>,
pub fields: Vec<Field>,
}Expand description
A complete datatype.
Fields§
§scalar: ScalarTypeThe scalar type, or ScalarType::Structured for a compound type.
size: u64Element size in bytes. Computed for numeric types; carried explicitly for strings, where it is the length in characters times the character width.
byteorder: ByteOrderByte order for this type’s elements, where it differs from the array’s.
shape: Vec<u64>Sub-array shape, for a field that is itself an array.
fields: Vec<Field>Fields, for a compound type.
Implementations§
Source§impl Datatype
impl Datatype
Sourcepub fn scalar(scalar: ScalarType) -> Datatype
pub fn scalar(scalar: ScalarType) -> Datatype
A plain scalar datatype.
Sourcepub fn string(scalar: ScalarType, length: u64) -> Datatype
pub fn string(scalar: ScalarType, length: u64) -> Datatype
A fixed-length string datatype, sized in characters.
Sourcepub fn is_structured(&self) -> bool
pub fn is_structured(&self) -> bool
Whether this is a compound type.
Sourcepub fn item_size(&self) -> u64
pub fn item_size(&self) -> u64
The size of one element in bytes.
For a compound type this is the sum of its fields; for a field with a
sub-array shape, the element size times the number of elements.
Saturating, because every input is a number out of the tree: a
compound type’s field list and a field’s own sub-array shape are both
attacker-controlled, and a wrapped item size is one a later bounds
check agrees with. There is no error channel here, so u64::MAX is
the honest answer for “does not fit” – no real element is that wide,
and every caller sizing a read against it then refuses.