Enum npyz::TypeChar

source ·
#[non_exhaustive]
pub enum TypeChar { Bool, Int, Uint, Float, Complex, TimeDelta, DateTime, ByteStr, UnicodeStr, RawData, }
Expand description

Represents the second character in a TypeStr.

Indicates the type of data stored. Affects the interpretation of TypeStr::size_field and TypeStr::endianness.

Complete documentation of which rust types can serialize as which dtypes can be found at type_matchup_docs.

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

Code b.

size must be 1, and legal values are 0x00 (false) or 0x01 (true).

§

Int

Code i.

Notice that numpy does not support 128-bit integers.

§

Uint

Code u.

Notice that numpy does not support 128-bit integers.

§

Float

Code f.

Notice that numpy does support 128-bit floats.

§

Complex

Code c. Represents a complex number.

The real part followed by the imaginary part, with size bytes total between the two of them. Each part has the specified endianness, but the real part always comes first.

You can deserialize this using the "complex" feature.

§

TimeDelta

Code m. Represents a numpy.timedelta64.

Can use i64 for serialization. size must be 8. Check TypeStr::time_units for the units.

§

DateTime

Code M. Represents a numpy.datetime64.

Can use i64 for serialization. size must be 8. Check TypeStr::time_units for the units.

§

ByteStr

Code S or a. Represents a zero-terminated Python 3 bytes (str in Python 2).

Can use Vec<u8> for serialization, or some other types; see type_matchup_docs for more info.

§

UnicodeStr

Code U. Represents a Python 3 str (unicode in Python 2).

A str that contains size code points (not bytes!). Each code unit is encoded as a 32-bit integer of the given endianness. Strings with fewer than size code units are zero-padded on the right. (thus they cannot contain trailing copies of U+0000 ‘NULL’; they can, however, contain interior copies)

Note the deliberate use of the term “code point” and not “scalar value”; values outside of the range [0, 0x110000) are forbidden, but surrogate code points are allowed.

See type_matchup_docs for information on which types can use this for serialization.

§

RawData

Code V. Represents a binary blob of size bytes.

Can use crate::FixedSizeBytes for serialization, or some other types; see type_matchup_docs for more info.

Implementations§

source§

impl TypeChar

source

pub fn from_char(s: char) -> Option<Self>

Parse a character into a datatype.

source

pub fn to_str(self) -> &'static str

Get the string representation of this datatype. e.g. "i".

Trait Implementations§

source§

impl Clone for TypeChar

source§

fn clone(&self) -> TypeChar

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for TypeChar

source§

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

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

impl Display for TypeChar

source§

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

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

impl Hash for TypeChar

source§

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

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 TypeChar

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for TypeChar

source§

impl Eq for TypeChar

source§

impl StructuralEq for TypeChar

source§

impl StructuralPartialEq for TypeChar

Auto Trait Implementations§

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> 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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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§

default 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>,

§

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>,

§

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.