Enum repr::ScalarType[][src]

pub enum ScalarType {
Show 26 variants Bool, Int16, Int32, Int64, Float32, Float64, Numeric { scale: Option<u8>, }, Date, Time, Timestamp, TimestampTz, Interval, Bytes, String, Char { length: Option<usize>, }, VarChar { length: Option<usize>, }, Jsonb, Uuid, Array(Box<ScalarType>), List { element_type: Box<ScalarType>, custom_oid: Option<u32>, }, Record { fields: Vec<(ColumnName, ColumnType)>, custom_oid: Option<u32>, custom_name: Option<String>, }, Oid, Map { value_type: Box<ScalarType>, custom_oid: Option<u32>, }, RegProc, RegType, RegClass,
}
Expand description

The type of a Datum.

There is a direct correspondence between Datum variants and ScalarType variants.

Variants

Bool

The type of Datum::True and Datum::False.

Int16

The type of Datum::Int16.

Int32

The type of Datum::Int32.

Int64

The type of Datum::Int64.

Float32

The type of Datum::Float32.

Float64

The type of Datum::Float64.

Numeric

Fields

scale: Option<u8>

The type of Datum::Numeric.

Numeric values cannot exceed NUMERIC_DATUM_MAX_PRECISION digits of precision.

This type additionally specifies the scale of the decimal. The scale specifies the number of digits after the decimal point. The scale must be less than or equal to the maximum precision.

Date

The type of Datum::Date.

Time

The type of Datum::Time.

Timestamp

The type of Datum::Timestamp.

TimestampTz

The type of Datum::TimestampTz.

Interval

The type of Datum::Interval.

Bytes

The type of Datum::Bytes.

String

The type of Datum::String.

Char

Fields

length: Option<usize>

Stored as Datum::String, but expresses a fixed-width, blank-padded string.

Note that a length of None is used in special cases, such as creating lists.

VarChar

Fields

length: Option<usize>

Stored as Datum::String, but can optionally express a limit on the string’s length.

Jsonb

The type of a datum that may represent any valid JSON value.

Valid datum variants for this type are:

Uuid

The type of Datum::Uuid.

Array(Box<ScalarType>)

Tuple Fields

The type of Datum::Array.

Elements within the array are of the specified type. It is illegal for the element type to be itself an array type. Array elements may always be Datum::Null.

List

Fields

element_type: Box<ScalarType>
custom_oid: Option<u32>

The type of Datum::List.

Elements within the list are of the specified type. List elements may always be Datum::Null.

Record

Fields

fields: Vec<(ColumnName, ColumnType)>

The names and types of the fields of the record, in order from left to right.

custom_oid: Option<u32>
custom_name: Option<String>

An ordered and named sequence of datums.

Oid

A PostgreSQL object identifier.

Map

Fields

value_type: Box<ScalarType>
custom_oid: Option<u32>

The type of Datum::Map

Keys within the map are always of type ScalarType::String. Values within the map are of the specified type. Values may always be Datum::Null.

RegProc

A PostgreSQL function name.

RegType

A PostgreSQL type name.

RegClass

A PostgreSQL class name.

Implementations

Returns the contained numeric scale.

Panics

Panics if the scalar type is not ScalarType::Numeric.

Returns the ScalarType of elements in a ScalarType::List.

Panics

Panics if called on anything other than a ScalarType::List.

Returns number of dimensions/axes (also known as “rank”) on a ScalarType::List.

Panics

Panics if called on anything other than a ScalarType::List.

Returns self with any embedded values set to a value appropriate for a collection of the type. Namely, this should set optional scales or limits to None.

Returns the ScalarType of elements in a ScalarType::Array.

Panics

Panics if called on anything other than a ScalarType::Array.

Returns the ScalarType of values in a ScalarType::Map.

Panics

Panics if called on anything other than a ScalarType::Map.

Returns the length of a ScalarType::Char or ScalarType::VarChar.

Panics

Panics if called on anything other than a ScalarType::Char or ScalarType::VarChar.

Derives a column type from this scalar type with the specified nullability.

Returns whether or not self is a vector-like type, i.e. ScalarType::List or ScalarType::Array, irrespective of its element type.

Determines equality among scalar types that acknowledges custom OIDs, but ignores other embedded values.

In most situations, you want to use base_eq rather than ScalarType’s implementation of Eq. base_eq expresses the semantics of direct type interoperability whereas Eq expresses an exact comparison between the values.

For instance, base_eq signals that e.g. two ScalarType::Numeric values can be added together, irrespective of their embedded scale. In contrast, two Numeric values with different scales are never Eq to one another.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Performs the conversion.

Performs the conversion.

Feeds this value into the given Hasher. Read more

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

Adds names and types of the fields of the struct or enum to rti. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

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

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more