pub struct TypeStr { /* private fields */ }
Expand description
Represents an Array Interface type-string.
This is more or less the DType
of a scalar type.
Exposes a FromStr
impl for construction,
and a Display
impl for writing.
use npyz::TypeStr;
let ts = "|i1".parse::<TypeStr>()?;
assert_eq!(format!("{}", ts), "|i1");
assert_eq!(ts.endianness(), npyz::Endianness::Irrelevant);
assert_eq!(ts.type_char(), npyz::TypeChar::Int);
assert_eq!(ts.size_field(), 1);
Implementations§
source§impl TypeStr
impl TypeStr
sourcepub fn endianness(&self) -> Endianness
pub fn endianness(&self) -> Endianness
Extract the endianness character from the type string.
sourcepub fn type_char(&self) -> TypeChar
pub fn type_char(&self) -> TypeChar
Extract the type character from the type string.
For most (but not all!) types, this is the number of bytes that a single value occupies.
For the U
type, it is the number of code units.
sourcepub fn size_field(&self) -> u64
pub fn size_field(&self) -> u64
Extract the “size” field from the type string. This is the number that appears after the type character.
For most (but not all!) types, this is the number of bytes that a single value occupies.
For the U
type, it is the number of code units.
sourcepub fn time_units(&self) -> Option<TimeUnits>
pub fn time_units(&self) -> Option<TimeUnits>
Extract the time units, if this type string has any. Only TypeChar::TimeDelta
and
TypeChar::DateTime
have time units.