pub enum Value {
}Expand description
A typed SQL value.
Represents values that can appear in query parameters, row data, and comparison predicates.
Note: Real and Decimal types use total ordering (NaN < -Inf < values < Inf) for comparisons to enable use in B+tree indexes.
Variants§
Null
SQL NULL.
TinyInt(i8)
8-bit signed integer (-128 to 127).
SmallInt(i16)
16-bit signed integer (-32,768 to 32,767).
Integer(i32)
32-bit signed integer (-2^31 to 2^31-1).
BigInt(i64)
64-bit signed integer (-2^63 to 2^63-1).
Real(f64)
64-bit floating point (IEEE 754 double precision).
Decimal(i128, u8)
Fixed-precision decimal (value in smallest units, scale).
Stored as (i128, u8) where the second field is the scale. Example: Decimal(12345, 2) represents 123.45
Text(String)
UTF-8 text string.
Bytes(Bytes)
Raw bytes (base64 encoded in JSON).
Boolean(bool)
Boolean value.
Date(i32)
Date (days since Unix epoch).
Time(i64)
Time of day (nanoseconds within day).
Timestamp(Timestamp)
Timestamp (nanoseconds since Unix epoch).
Uuid([u8; 16])
UUID (RFC 4122, 128-bit).
Json(Value)
JSON document (validated).
Placeholder(usize)
Parameter placeholder ($1, $2, etc.) - 1-indexed. This is an intermediate representation used during parsing, and should be bound to actual values before execution.
Implementations§
Source§impl Value
impl Value
Sourcepub fn data_type(&self) -> Option<DataType>
pub fn data_type(&self) -> Option<DataType>
Returns the data type of this value.
Returns None for Null and Placeholder since they have no concrete type.
Sourcepub fn as_boolean(&self) -> Option<bool>
pub fn as_boolean(&self) -> Option<bool>
Returns the value as a bool, if it is Boolean.
Sourcepub fn as_timestamp(&self) -> Option<Timestamp>
pub fn as_timestamp(&self) -> Option<Timestamp>
Returns the value as a Timestamp, if it is Timestamp.
Sourcepub fn as_tinyint(&self) -> Option<i8>
pub fn as_tinyint(&self) -> Option<i8>
Returns the value as an i8, if it is a TinyInt.
Sourcepub fn as_smallint(&self) -> Option<i16>
pub fn as_smallint(&self) -> Option<i16>
Returns the value as an i16, if it is a SmallInt.
Sourcepub fn as_integer(&self) -> Option<i32>
pub fn as_integer(&self) -> Option<i32>
Returns the value as an i32, if it is an Integer.
Sourcepub fn as_decimal(&self) -> Option<(i128, u8)>
pub fn as_decimal(&self) -> Option<(i128, u8)>
Returns the value as a Decimal (value, scale), if it is a Decimal.
Sourcepub fn compare(&self, other: &Value) -> Option<Ordering>
pub fn compare(&self, other: &Value) -> Option<Ordering>
Compares two values for ordering.
NULL values are considered less than all non-NULL values. Values of different types return None (incomparable).
For Real values, uses total ordering: NaN < -Inf < values < Inf.
Sourcepub fn is_compatible_with(&self, data_type: DataType) -> bool
pub fn is_compatible_with(&self, data_type: DataType) -> bool
Checks if this value can be assigned to a column of the given type.