pub enum Value {
}Expand description
A single SQL value returned from or passed to a query.
Covers both the basic scalar types common to all databases and extended types for dates, timestamps, UUIDs, JSON, exact decimals, and arrays.
Variants§
Null
SQL NULL.
Bool(bool)
Boolean value.
I64(i64)
64-bit signed integer.
F64(f64)
64-bit floating-point number.
Text(String)
UTF-8 text string.
Blob(Vec<u8>)
Raw binary data.
Timestamp(i64)
Unix timestamp with microsecond precision (microseconds since epoch,
UTC). Maps to SQL TIMESTAMP / TIMESTAMPTZ.
Date(i32)
Date-only value as days since Unix epoch (1970-01-01).
Maps to SQL DATE.
Time(i64)
Time-of-day value as microseconds since midnight.
Maps to SQL TIME.
Uuid(u128)
UUID stored as a 128-bit unsigned integer.
Maps to SQL UUID.
Json(String)
JSON or JSONB data stored as a UTF-8 string.
Maps to SQL JSON / JSONB.
Decimal(String)
Exact decimal stored as a string representation (e.g. "123.456").
Using a string avoids introducing a big-decimal dependency at the
core level while preserving exact precision.
Maps to SQL NUMERIC / DECIMAL.
Array(Vec<Value>)
Ordered array of values (e.g. Postgres INTEGER[], TEXT[]).
TypedArray
Like Value::Array but also carries the nominal element type returned
by the backend (e.g. PostgreSQL int4[] → TypedArray { element_type: Int4, .. }).
Fields
element_type: ArrayElementTypeThe nominal SQL element type of this array.
Implementations§
Trait Implementations§
Source§impl<'a> From<&'a Value> for BorrowedValue<'a>
impl<'a> From<&'a Value> for BorrowedValue<'a>
Source§fn from(v: &'a Value) -> Self
fn from(v: &'a Value) -> Self
Borrow a Value as a BorrowedValue with zero allocation.
Text, Blob, Json, and Decimal borrow from the owned Value.
Array borrows from a freshly-allocated intermediate Vec of
BorrowedValues; use BorrowedValue::to_owned to get back an
owned Value when needed.
Source§impl PartialOrd for Value
impl PartialOrd for Value
impl StructuralPartialEq for Value
Source§impl ToSqlValue for Value
Allow a Value to be used directly as a SQL parameter.
impl ToSqlValue for Value
Allow a Value to be used directly as a SQL parameter.
This enables fan-out helpers (e.g. MultiConnection) to collect
parameter snapshots as Vec<Value> and pass them back to
Connection::execute / Connection::query without an intermediate
conversion step.