Enum repr::scalar::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
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
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
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
0: Box<ScalarType>
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
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.
An ordered and named sequence of datums.
Oid
A PostgreSQL object identifier.
Map
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 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
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Performs the conversion.
Performs the conversion.
Adds names and types of the fields of the struct or enum to rti
. 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
Auto Trait Implementations
impl RefUnwindSafe for ScalarType
impl Send for ScalarType
impl Sync for ScalarType
impl Unpin for ScalarType
impl UnwindSafe for ScalarType
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.
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