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 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.
Sourcepub fn time_units(&self) -> Option<TimeUnits>
pub fn time_units(&self) -> Option<TimeUnits>
Sourcepub fn num_bytes(&self) -> Option<usize>
pub fn num_bytes(&self) -> Option<usize>
Get the number of bytes for a single value.
If this size is not fixed (e.g. |O) or would overflow the platform’s usize type, returns None.
You can differentiate between these two error cases by calling [Self::has_variable_size].
Sourcepub fn uses_pickled_array(&self) -> bool
pub fn uses_pickled_array(&self) -> bool
Returns true if an array using this DType is stored using pickle.
Pickled arrays present unique challenges, and most of the npyz crate does not support them.
Trait Implementations§
impl Eq for TypeStr
impl StructuralPartialEq for TypeStr
Auto Trait Implementations§
impl Freeze for TypeStr
impl RefUnwindSafe for TypeStr
impl Send for TypeStr
impl Sync for TypeStr
impl Unpin for TypeStr
impl UnsafeUnpin for TypeStr
impl UnwindSafe for TypeStr
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
Mutably borrows from an owned value. Read more