Skip to main content

Datum

Enum Datum 

Source
pub enum Datum {
Show 14 variants Null, Bool(bool), Int2(i16), Int4(i32), Int8(i64), Float4(f32), Float8(f64), Oid(Oid), Text(String), Bytea(Vec<u8>), Uuid([u8; 16]), Date(i32), Timestamp(i64), TimestampTz(i64),
}
Expand description

One value. Null has no type.

Variants§

§

Null

SQL NULL.

§

Bool(bool)

bool.

§

Int2(i16)

int2.

§

Int4(i32)

int4.

§

Int8(i64)

int8.

§

Float4(f32)

float4.

§

Float8(f64)

float8.

§

Oid(Oid)

oid.

§

Text(String)

text.

§

Bytea(Vec<u8>)

bytea.

§

Uuid([u8; 16])

uuid, the 16 bytes in the order of the text form.

§

Date(i32)

date, the days since 1 January 2000. i32::MAX is infinity and i32::MIN is -infinity.

§

Timestamp(i64)

timestamp, the microseconds since 1 January 2000. i64::MAX is infinity and i64::MIN is -infinity.

§

TimestampTz(i64)

timestamptz, the microseconds since 1 January 2000 UTC, with the infinities of timestamp.

Implementations§

Source§

impl Datum

Source

pub fn type_id(&self) -> Option<TypeId>

The type of the value, or None for Null.

Source

pub fn is_null(&self) -> bool

True for Null.

Source

pub fn encode(&self) -> Option<Vec<u8>>

The storage form, or None for Null.

Source

pub fn decode(ty: TypeId, bytes: Option<&[u8]>) -> Result<Datum>

The value of type ty in the storage form bytes. None is Null. A storage form of the wrong length, a bool that is not 0 or 1, or text that is not UTF-8 gives SQLSTATE XX001, because only the engine writes the storage form. A type that M1 does not store gives XX000.

Trait Implementations§

Source§

impl Clone for Datum

Source§

fn clone(&self) -> Self

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 Datum

Source§

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

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

impl PartialEq for Datum

Source§

fn eq(&self, other: &Self) -> 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 Datum

Auto Trait Implementations§

§

impl Freeze for Datum

§

impl RefUnwindSafe for Datum

§

impl Send for Datum

§

impl Sync for Datum

§

impl Unpin for Datum

§

impl UnsafeUnpin for Datum

§

impl UnwindSafe for Datum

Blanket Implementations§

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