Skip to main content

DataType

Enum DataType 

Source
#[non_exhaustive]
pub enum DataType {
Show 13 variants Any, Unknown, Boolean, Integer, Float, Decimal { precision: Option<u32>, scale: Option<i32>, }, String, Binary, Date, Timestamp { timezone: Option<String>, }, List(Box<Field>), Struct(Vec<Field>), Map { key: Box<Field>, value: Box<Field>, },
}
Expand description

A field’s logical type.

Scalars are the types tabular formats share; List, Struct and Map nest. Any is a type the source declares to accept anything (JSON Schema’s {}); Unknown is one the source did not say or a reader could not tell (an empty column, a type a mapping does not know).

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.
§

Any

Accepts any value.

§

Unknown

Not known.

§

Boolean

true or false.

§

Integer

A whole number, of any width or signedness.

§

Float

A binary floating-point number.

§

Decimal

A fixed-point decimal, with its precision (total digits) and scale (digits after the point) when the source gives them.

Fields

§precision: Option<u32>

Total digits.

§scale: Option<i32>

Digits after the decimal point.

§

String

Text.

§

Binary

Bytes.

§

Date

A calendar date.

§

Timestamp

A date and time, with its time zone when the source gives one.

Fields

§timezone: Option<String>

The time zone, as the source writes it (UTC, +01:00).

§

List(Box<Field>)

A sequence of items, each described by the field.

§

Struct(Vec<Field>)

Named fields.

§

Map

Keys to values.

Fields

§key: Box<Field>

The key field.

§value: Box<Field>

The value field.

Implementations§

Source§

impl DataType

Source

pub fn list(item: DataType) -> DataType

A list of nullable items, under the conventional name item.

Source

pub fn map(key: DataType, value: DataType) -> DataType

A map from non-null keys to nullable values, under the conventional names key and value.

Source

pub fn timestamp() -> DataType

A timestamp without a time zone.

Source

pub fn decimal() -> DataType

A decimal without a stated precision or scale.

Source

pub fn is_numeric(&self) -> bool

Whether values of this type are numbers (integer, float or decimal).

Source

pub fn is_nested(&self) -> bool

Whether this type nests other fields (list, struct or map).

Source

pub fn children(&self) -> impl Iterator<Item = &Field>

The fields this type nests: a struct’s fields, a list’s item, a map’s key and value. Empty for scalars.

Trait Implementations§

Source§

impl Clone for DataType

Source§

fn clone(&self) -> DataType

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 DataType

Source§

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

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

impl Display for DataType

The lowercase name: integer, decimal(10,2), timestamp[UTC], list<string>, map<string, integer>, struct.

Source§

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

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

impl Eq for DataType

Source§

impl Hash for DataType

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 DataType

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for DataType

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToCompactString for T
where T: Display,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.