[][src]Enum dbcrossbarlib::schema::DataType

pub enum DataType {
    Array(Box<DataType>),
    Bool,
    Date,
    Decimal,
    Float32,
    Float64,
    GeoJson(Srid),
    Int16,
    Int32,
    Int64,
    Json,
    Other(String),
    Text,
    TimestampWithoutTimeZone,
    TimestampWithTimeZone,
    Uuid,
}

The data type of a column.

This is a rather interesting type: It only exists to provide a reasonable set of "interchange" types, that we might want to preserve when moving from on database to another. So it's less precise than PostgreSQL's built-in types, but more precise than BigQuery's built-in types. It exists to be a "happy medium"--every output driver should be able to understand every one of these types meaningfully, and it should almost always be able to map it to something in the local database.

Essentially, this fulfills a similar role to the standard JSON types (number, string, array, map, boolean, etc.). It's an interchange format. It's not supposed to cover every imaginable type. But it should at least cover common, generic types that make sense to many database backends.

We represent this as a Rust enum, and not a class hierarchy, because:

  1. Class hierarchies provide an extensible set of types (subclasses), but a closed set of operations (instance methods on the root class).
  2. Rust enums provide a closed set of types (enum variants), but an open set of operations (match statements matching each possible variant).

In this case, we will extend and change our set of operations regularly, as we add new input and output filters. But we will only change the possible data types after careful deliberation. So enum is the better choice here.

Variants

Array(Box<DataType>)

An array of another data type. For many output formats, it may not be possible to nest arrays.

Bool

A boolean value.

Date

A date, with no associated time value.

Decimal

A decimal integer (can represent currency, etc., without rounding errors).

Float32

4-byte float.

Float64

8-byte float.

GeoJson(Srid)

Geodata in GeoJSON format, using the specified SRID.

Int16

2-byte int.

Int32

4-byte integer.

Int64

8-byte integer.

Json

JSON data. This includes both Postgres json and jsonb types, the differences between which don't usually matter when converting schemas.

Other(String)

A data type which isn't in this list.

Text

A text type.

TimestampWithoutTimeZone

A timestamp with no timezone. Ideally, this will would be in UTC, and some systems like BigQuery may automatically assume that.

TimestampWithTimeZone

A timestamp with a timezone.

Uuid

A UUID.

Trait Implementations

impl Clone for DataType[src]

impl Debug for DataType[src]

impl<'de> Deserialize<'de> for DataType[src]

impl Eq for DataType[src]

impl PartialEq<DataType> for DataType[src]

impl Serialize for DataType[src]

impl StructuralEq for DataType[src]

impl StructuralPartialEq for DataType[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

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

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> IntoSql for T[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> SendSyncUnwindSafe for T where
    T: Send + Sync + UnwindSafe + ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,