pub enum Datum<'a> {
Show 30 variants
False,
True,
Int16(i16),
Int32(i32),
Int64(i64),
UInt8(u8),
UInt16(u16),
UInt32(u32),
UInt64(u64),
Float32(OrderedFloat<f32>),
Float64(OrderedFloat<f64>),
Date(Date),
Time(NaiveTime),
Timestamp(CheckedTimestamp<NaiveDateTime>),
TimestampTz(CheckedTimestamp<DateTime<Utc>>),
Interval(Interval),
Bytes(&'a [u8]),
String(&'a str),
Array(Array<'a>),
List(DatumList<'a>),
Map(DatumMap<'a>),
Numeric(OrderedDecimal<Numeric>),
JsonNull,
Uuid(Uuid),
MzTimestamp(Timestamp),
Range(Range<DatumNested<'a>>),
MzAclItem(MzAclItem),
AclItem(AclItem),
Dummy,
Null,
}
Expand description
A single value.
§Notes
§Equality
Datum
must always derive Eq
to enforce equality with repr::Row
.
§Datum
-containing types
Because Rust disallows recursive enums, complex types which need to contain
other Datum
s instead store bytes representing that data in other structs,
usually prefixed with Datum
(e.g. DatumList
). These types perform a form
of ad-hoc deserialization of their inner bytes to Datum
s via
crate::row::read_datum
.
To create a new instance of a Datum
-referencing Datum
, you need to store
the inner Datum
’s bytes in a row (so you can in turn borrow those bytes in
the outer Datum
). The idiom we’ve devised for this is a series of
functions on repr::row::RowPacker
prefixed with push_
.
Variants§
False
The false
boolean value.
True
The true
boolean value.
Int16(i16)
A 16-bit signed integer.
Int32(i32)
A 32-bit signed integer.
Int64(i64)
A 64-bit signed integer.
UInt8(u8)
An 8-bit unsigned integer.
UInt16(u16)
An 16-bit unsigned integer.
UInt32(u32)
A 32-bit unsigned integer.
UInt64(u64)
A 64-bit unsigned integer.
Float32(OrderedFloat<f32>)
A 32-bit floating point number.
Float64(OrderedFloat<f64>)
A 64-bit floating point number.
Date(Date)
A date.
Time(NaiveTime)
A time.
Timestamp(CheckedTimestamp<NaiveDateTime>)
A date and time, without a timezone.
Note that this is not crate::Timestamp
! That’s in Datum::MzTimestamp
.
TimestampTz(CheckedTimestamp<DateTime<Utc>>)
A date and time, with a timezone.
Interval(Interval)
A span of time.
Bytes(&'a [u8])
A sequence of untyped bytes.
String(&'a str)
A sequence of Unicode codepoints encoded as UTF-8.
Array(Array<'a>)
Unlike Datum::List
, arrays are like tensors and are not permitted to
be ragged.
List(DatumList<'a>)
A sequence of Datum
s.
Unlike Datum::Array
, lists are permitted to be ragged.
Map(DatumMap<'a>)
A mapping from string keys to Datum
s.
Numeric(OrderedDecimal<Numeric>)
An exact decimal number, possibly with a fractional component, with up to 39 digits of precision.
JsonNull
An unknown value within a JSON-typed Datum
.
This variant is distinct from Datum::Null
as a null datum is
distinct from a non-null datum that contains the JSON value null
.
Uuid(Uuid)
A universally unique identifier.
MzTimestamp(Timestamp)
Range(Range<DatumNested<'a>>)
A range of values, e.g. [-1, 1).
MzAclItem(MzAclItem)
A list of privileges granted to a user, that uses RoleId
s for role
references.
AclItem(AclItem)
A list of privileges granted to a user that uses Oid
s for role references.
This type is used primarily for compatibility with PostgreSQL.
Dummy
A placeholder value.
Dummy values are never meant to be observed. Many operations on Datum
panic if called on this variant.
Dummies are useful as placeholders in e.g. a Vec<Datum>
, where it is
known that a certain element of the vector is never observed and
therefore needn’t be computed, but where some Datum
must still be
provided to maintain the shape of the vector. While any valid datum
could be used for this purpose, having a dedicated variant makes it
obvious when these optimizations have gone awry. If we used e.g.
Datum::Null
, an unexpected Datum::Null
could indicate any number of
problems: bad user data, bad function metadata, or a bad optimization.
Null
An unknown value.
Implementations§
source§impl<'a> Datum<'a>
impl<'a> Datum<'a>
sourcepub fn is_null(&self) -> bool
pub fn is_null(&self) -> bool
Reports whether this datum is null (i.e., is Datum::Null
).
sourcepub fn unwrap_bool(&self) -> bool
pub fn unwrap_bool(&self) -> bool
Unwraps the boolean value within this datum.
§Panics
Panics if the datum is not Datum::False
or Datum::True
.
sourcepub fn unwrap_int16(&self) -> i16
pub fn unwrap_int16(&self) -> i16
Unwraps the 16-bit integer value within this datum.
§Panics
Panics if the datum is not Datum::Int16
.
sourcepub fn unwrap_int32(&self) -> i32
pub fn unwrap_int32(&self) -> i32
Unwraps the 32-bit integer value within this datum.
§Panics
Panics if the datum is not Datum::Int32
.
sourcepub fn unwrap_int64(&self) -> i64
pub fn unwrap_int64(&self) -> i64
Unwraps the 64-bit integer value within this datum.
§Panics
Panics if the datum is not Datum::Int64
.
sourcepub fn unwrap_uint8(&self) -> u8
pub fn unwrap_uint8(&self) -> u8
Unwraps the 8-bit unsigned integer value within this datum.
§Panics
Panics if the datum is not Datum::UInt8
.
sourcepub fn unwrap_uint16(&self) -> u16
pub fn unwrap_uint16(&self) -> u16
Unwraps the 16-bit unsigned integer value within this datum.
§Panics
Panics if the datum is not Datum::UInt16
.
sourcepub fn unwrap_uint32(&self) -> u32
pub fn unwrap_uint32(&self) -> u32
Unwraps the 32-bit unsigned integer value within this datum.
§Panics
Panics if the datum is not Datum::UInt32
.
sourcepub fn unwrap_uint64(&self) -> u64
pub fn unwrap_uint64(&self) -> u64
Unwraps the 64-bit unsigned integer value within this datum.
§Panics
Panics if the datum is not Datum::UInt64
.
pub fn unwrap_ordered_float32(&self) -> OrderedFloat<f32>
pub fn unwrap_ordered_float64(&self) -> OrderedFloat<f64>
sourcepub fn unwrap_float32(&self) -> f32
pub fn unwrap_float32(&self) -> f32
Unwraps the 32-bit floating-point value within this datum.
§Panics
Panics if the datum is not Datum::Float32
.
sourcepub fn unwrap_float64(&self) -> f64
pub fn unwrap_float64(&self) -> f64
Unwraps the 64-bit floating-point value within this datum.
§Panics
Panics if the datum is not Datum::Float64
.
sourcepub fn unwrap_date(&self) -> Date
pub fn unwrap_date(&self) -> Date
sourcepub fn unwrap_time(&self) -> NaiveTime
pub fn unwrap_time(&self) -> NaiveTime
sourcepub fn unwrap_timestamp(&self) -> CheckedTimestamp<NaiveDateTime>
pub fn unwrap_timestamp(&self) -> CheckedTimestamp<NaiveDateTime>
sourcepub fn unwrap_timestamptz(&self) -> CheckedTimestamp<DateTime<Utc>>
pub fn unwrap_timestamptz(&self) -> CheckedTimestamp<DateTime<Utc>>
Unwraps the timestamptz value within this datum.
§Panics
Panics if the datum is not Datum::TimestampTz
.
sourcepub fn unwrap_interval(&self) -> Interval
pub fn unwrap_interval(&self) -> Interval
sourcepub fn unwrap_str(&self) -> &'a str
pub fn unwrap_str(&self) -> &'a str
sourcepub fn unwrap_bytes(&self) -> &'a [u8] ⓘ
pub fn unwrap_bytes(&self) -> &'a [u8] ⓘ
sourcepub fn unwrap_uuid(&self) -> Uuid
pub fn unwrap_uuid(&self) -> Uuid
sourcepub fn unwrap_array(&self) -> Array<'a>
pub fn unwrap_array(&self) -> Array<'a>
sourcepub fn unwrap_list(&self) -> DatumList<'a>
pub fn unwrap_list(&self) -> DatumList<'a>
sourcepub fn unwrap_map(&self) -> DatumMap<'a>
pub fn unwrap_map(&self) -> DatumMap<'a>
sourcepub fn unwrap_numeric(&self) -> OrderedDecimal<Numeric>
pub fn unwrap_numeric(&self) -> OrderedDecimal<Numeric>
sourcepub fn unwrap_mz_timestamp(&self) -> Timestamp
pub fn unwrap_mz_timestamp(&self) -> Timestamp
Unwraps the mz_repr::Timestamp value within this datum.
§Panics
Panics if the datum is not Datum::MzTimestamp
.
sourcepub fn unwrap_range(&self) -> Range<Datum<'a>>
pub fn unwrap_range(&self) -> Range<Datum<'a>>
Unwraps the range value within this datum.
Note that the return type is a range generic over Datum
, which is
convenient to work with. However, the type stored in the datum is
generic over DatumNested
, which is necessary to avoid needless boxing
of the inner Datum
.
§Panics
Panics if the datum is not Datum::Range
.
sourcepub fn unwrap_mz_acl_item(&self) -> MzAclItem
pub fn unwrap_mz_acl_item(&self) -> MzAclItem
Unwraps the mz_acl_item value within this datum.
§Panics
Panics if the datum is not Datum::MzAclItem
.
sourcepub fn unwrap_acl_item(&self) -> AclItem
pub fn unwrap_acl_item(&self) -> AclItem
sourcepub fn is_instance_of(self, column_type: &ColumnType) -> bool
pub fn is_instance_of(self, column_type: &ColumnType) -> bool
Reports whether this datum is an instance of the specified column type.
Trait Implementations§
source§impl<'a, E> DatumType<'a, E> for Datum<'a>
impl<'a, E> DatumType<'a, E> for Datum<'a>
source§impl<'a> From<CheckedTimestamp<NaiveDateTime>> for Datum<'a>
impl<'a> From<CheckedTimestamp<NaiveDateTime>> for Datum<'a>
source§fn from(dt: CheckedTimestamp<NaiveDateTime>) -> Datum<'a>
fn from(dt: CheckedTimestamp<NaiveDateTime>) -> Datum<'a>
source§impl<'a> From<Datum<'a>> for ProtoDatum
impl<'a> From<Datum<'a>> for ProtoDatum
source§impl<'a> Ord for Datum<'a>
impl<'a> Ord for Datum<'a>
source§impl<'a> PartialOrd for Datum<'a>
impl<'a> PartialOrd for Datum<'a>
source§impl TryFrom<Datum<'_>> for CheckedTimestamp<NaiveDateTime>
impl TryFrom<Datum<'_>> for CheckedTimestamp<NaiveDateTime>
source§impl TryFrom<Datum<'_>> for NaiveDateTime
impl TryFrom<Datum<'_>> for NaiveDateTime
source§impl<'a> TryInto<Datum<'a>> for NaiveDateTime
impl<'a> TryInto<Datum<'a>> for NaiveDateTime
impl<'a> Copy for Datum<'a>
impl<'a> Eq for Datum<'a>
impl<'a> StructuralPartialEq for Datum<'a>
Auto Trait Implementations§
impl<'a> Freeze for Datum<'a>
impl<'a> RefUnwindSafe for Datum<'a>
impl<'a> Send for Datum<'a>
impl<'a> Sync for Datum<'a>
impl<'a> Unpin for Datum<'a>
impl<'a> UnwindSafe for Datum<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
source§impl<T, U> OverrideFrom<Option<&T>> for Uwhere
U: OverrideFrom<T>,
impl<T, U> OverrideFrom<Option<&T>> for Uwhere
U: OverrideFrom<T>,
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> PreferredContainer for T
impl<T> PreferredContainer for T
source§impl<T> ProgressEventTimestamp for T
impl<T> ProgressEventTimestamp for T
source§impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
source§fn into_rust(self) -> Result<R, TryFromProtoError>
fn into_rust(self) -> Result<R, TryFromProtoError>
RustType::from_proto
.source§fn from_rust(rust: &R) -> P
fn from_rust(rust: &R) -> P
RustType::into_proto
.source§impl<'a, S, T> Semigroup<&'a S> for Twhere
T: Semigroup<S>,
impl<'a, S, T> Semigroup<&'a S> for Twhere
T: Semigroup<S>,
source§fn plus_equals(&mut self, rhs: &&'a S)
fn plus_equals(&mut self, rhs: &&'a S)
std::ops::AddAssign
, for types that do not implement AddAssign
.