Skip to main content

DType

Enum DType 

Source
#[non_exhaustive]
pub enum DType {
Show 22 variants Bool, U8, U16, U32, U64, U128, I8, I16, I32, I64, I128, I256, F32, F64, Complex32, Complex64, DateTime64(TimeUnit), Timedelta64(TimeUnit), Struct(&'static [FieldDescriptor]), FixedAscii(usize), FixedUnicode(usize), RawBytes(usize),
}
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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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

Source

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.

Source

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.

Source

pub const fn is_float(self) -> bool

true if the dtype is a floating-point type (f16, bf16, f32, f64).

Source

pub const fn is_integer(self) -> bool

true if the dtype is an integer type (signed or unsigned, including bool).

Source

pub const fn is_complex(self) -> bool

true if the dtype is a complex type.

Source

pub const fn is_signed(self) -> bool

true if the dtype is a signed numeric type.

Trait Implementations§

Source§

impl Clone for DType

Source§

fn clone(&self) -> DType

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for DType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Hash for DType

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for DType

Source§

fn eq(&self, other: &DType) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for DType

Source§

impl Eq for DType

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.