#[non_exhaustive]pub enum DType {
}Expand description
Runtime descriptor for the element type stored in an array.
Mirrors the set of types implementing Element.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Bool
bool
U8
u8
U16
u16
U32
u32
U64
u64
U128
u128
I8
i8
I16
i16
I32
i32
I64
i64
I128
i128
I256
I256 — 256-bit two’s-complement signed integer. Used as
the promoted type for mixed u128 + i128 arithmetic
(no native Rust type can hold that union losslessly).
F32
f32
F64
f64
Complex32
Complex<f32>
Complex64
Complex<f64>
DateTime64(TimeUnit)
datetime64[unit] — calendar instant as i64 ticks since the Unix
epoch, with the TimeUnit tagging the meaning of one tick.
Backed by the DateTime64 element type.
Timedelta64(TimeUnit)
timedelta64[unit] — duration as i64 ticks. Backed by the
Timedelta64 element type.
Struct(&'static [FieldDescriptor])
Structured (record) dtype holding a static descriptor for each field (#342). Mirrors numpy’s structured dtype:
np.dtype([('x', 'f4'), ('y', 'f4')])The slice is &'static so that DType stays Copy. The
FerrayRecord derive macro emits exactly this shape via
Type::field_descriptors() -> &'static [FieldDescriptor],
so the typical construction site is:
let dt = DType::Struct(<Point as FerrayRecord>::field_descriptors());Dynamically-constructed descriptors must be leaked into a
&'static [FieldDescriptor] (e.g. via Box::leak); ferray-core
does not allocate field descriptors at runtime.
FixedAscii(usize)
Fixed-width ASCII string with n bytes per element. Mirrors
numpy’s 'S{n}' dtype family. Backed by [u8; n] rows in a
flat byte buffer; trailing zeros pad short strings (#741).
FixedUnicode(usize)
Fixed-width Unicode string with n codepoints per element
stored as UCS-4 (4 * n bytes per element). Mirrors numpy’s
'U{n}' dtype family (#741).
RawBytes(usize)
Fixed-width raw byte / void dtype with n bytes per
element. Mirrors numpy’s 'V{n}' dtype family — opaque
fixed-size byte payloads with no UTF-8 / ASCII assumption
(#741).
Implementations§
Source§impl DType
impl DType
Sourcepub fn size_of(self) -> usize
pub fn size_of(self) -> usize
Size in bytes of one element of this dtype.
Note: lost const-ness when Self::Struct was added (#342) —
computing struct size requires iterating field descriptors,
which stable const fn doesn’t support yet.
Sourcepub fn alignment(self) -> usize
pub fn alignment(self) -> usize
Required alignment in bytes for this dtype.
Note: lost const-ness with Self::Struct (#342) — struct
alignment is the max of field alignments, which requires
iterating field descriptors.
Sourcepub const fn is_float(self) -> bool
pub const fn is_float(self) -> bool
true if the dtype is a floating-point type (f16, bf16, f32, f64).
Sourcepub const fn is_integer(self) -> bool
pub const fn is_integer(self) -> bool
true if the dtype is an integer type (signed or unsigned, including bool).
Sourcepub const fn is_complex(self) -> bool
pub const fn is_complex(self) -> bool
true if the dtype is a complex type.
Trait Implementations§
impl Copy for DType
impl Eq for DType
impl StructuralPartialEq for DType
Auto Trait Implementations§
impl Freeze for DType
impl RefUnwindSafe for DType
impl Send for DType
impl Sync for DType
impl Unpin for DType
impl UnsafeUnpin for DType
impl UnwindSafe for DType
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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