Skip to main content

Value

Enum Value 

Source
#[non_exhaustive]
pub enum Value {
Show 17 variants SmallInt(i16), Int(i32), BigInt(i64), Float(f64), Text(String), Bool(bool), Vector(Vec<f32>), Sq8Vector(Sq8Vector), HalfVector(HalfVector), Numeric { scaled: i128, scale: u8, }, Date(i32), Timestamp(i64), Interval { months: i32, micros: i64, }, Json(String), Bytes(Vec<u8>), TextArray(Vec<Option<String>>), Null,
}
Expand description

A row-cell value, including SQL NULL. Float uses f64; NaN compares non-equal to itself (PG behaviour) — PartialEq is derived so callers must opt into NaN-aware comparison if they need stronger guarantees.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

SmallInt(i16)

§

Int(i32)

§

BigInt(i64)

§

Float(f64)

§

Text(String)

§

Bool(bool)

§

Vector(Vec<f32>)

§

Sq8Vector(Sq8Vector)

v6.0.1: 8-bit scalar-quantised vector cell. Lives in columns declared VECTOR(N) USING SQ8. Layout per cell: Sq8Vector { min: f32, max: f32, bytes: Vec<u8> } — 4× compression vs Vector(Vec<f32>). The wire layer dequantises to f32 on SELECT; INSERT path quantises incoming Vector(Vec<f32>) cells into this variant.

§

HalfVector(HalfVector)

v6.0.3: IEEE-754 binary16 vector cell. Lives in columns declared VECTOR(N) USING HALF. Stores raw u16 LE bits (2× compression vs Vector(Vec<f32>)). Wire / display paths dequantise to f32 bit-exactly; INSERT path converts incoming f32 vectors at the engine boundary.

§

Numeric

Exact fixed-point decimal. scaled holds the value as actual * 10^scale so the storage type is always integral — arithmetic never falls back to floating-point.

Fields

§scaled: i128
§scale: u8
§

Date(i32)

Days since the Unix epoch (1970-01-01). Negative for earlier dates.

§

Timestamp(i64)

Microseconds since the Unix epoch (1970-01-01T00:00:00Z).

§

Interval

Calendar span: months (variable-length) + micros (fixed-length). Runtime-only — cannot appear in a stored row in v2.11.

Fields

§months: i32
§micros: i64
§

Json(String)

v4.9 JSON — raw JSON text. No structural validation happens at the storage layer; whatever the parser hands us round-trips verbatim. Equality is byte-wise.

§

Bytes(Vec<u8>)

v7.10.4 BYTEA — raw binary blob. Equality is byte-wise. Layout matches Text’s length-prefixed shape ([u32 LE len][bytes]) under tag 18; the engine accepts PG hex literals ('\xDEADBEEF') and escape literals at the coercion boundary.

§

TextArray(Vec<Option<String>>)

v7.10.9 TEXT[] — single-dimension TEXT array with optional NULL elements. Equality is element-wise. PG’s NULL-element comparison semantics: NULL ≠ NULL inside arrays under =, so [NULL] != [NULL] (the engine honours this).

§

Null

Implementations§

Source§

impl Value

Source

pub fn data_type(&self) -> Option<DataType>

Type tag, or None for NULL (unknown at value level).

Source

pub const fn is_null(&self) -> bool

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

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 Value

Source§

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

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

impl PartialEq for Value

Source§

fn eq(&self, other: &Value) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Value

Auto Trait Implementations§

§

impl Freeze for Value

§

impl RefUnwindSafe for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin for Value

§

impl UnsafeUnpin for Value

§

impl UnwindSafe for Value

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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.