Enum Value
pub enum Value {
Show 23 variants
Bool(bool),
I8(i8),
I16(i16),
I32(i32),
I64(i64),
U8(u8),
U16(u16),
U32(u32),
U64(u64),
SparseRecord(SparseRecord),
Null,
Record(ValueRecord),
List(Vec<Value>),
String(String),
Bytes(Vec<u8>),
Uuid(Uuid),
Decimal(Decimal),
BigDecimal(BigDecimal),
Timestamp(Timestamp),
Zoned(Zoned),
Date(Date),
Time(Time),
DateTime(DateTime),
}Expand description
A dynamically typed value used throughout Toasty’s query engine.
Value represents any concrete data value that flows through the query
pipeline: field values read from or written to the database, literal
constants in expressions, and intermediate results during query evaluation.
Each variant wraps a Rust type that corresponds to a Type variant.
Use Value::infer_ty to obtain the matching type, and Value::is_a
to check compatibility.
§Construction
Values are typically created via From conversions from Rust primitives:
use toasty_core::stmt::Value;
let v = Value::from(42_i64);
assert_eq!(v, 42_i64);
let v = Value::from("hello");
assert_eq!(v, "hello");
let v = Value::null();
assert!(v.is_null());
let v = Value::from(true);
assert_eq!(v, true);Variants§
Bool(bool)
Boolean value
I8(i8)
Signed 8-bit integer
I16(i16)
Signed 16-bit integer
I32(i32)
Signed 32-bit integer
I64(i64)
Signed 64-bit integer
U8(u8)
Unsigned 8-bit integer
U16(u16)
Unsigned 16-bit integer
U32(u32)
Unsigned 32-bit integer
U64(u64)
Unsigned 64-bit integer
SparseRecord(SparseRecord)
A typed record
Null
Null value
Record(ValueRecord)
Record value, either borrowed or owned
List(Vec<Value>)
A list of values of the same type
String(String)
String value, either borrowed or owned
Bytes(Vec<u8>)
An array of bytes that is more efficient than List(u8)
Uuid(Uuid)
128-bit universally unique identifier (UUID)
Decimal(Decimal)
A fixed-precision decimal number.
See [rust_decimal::Decimal].
BigDecimal(BigDecimal)
An arbitrary-precision decimal number.
See [bigdecimal::BigDecimal].
Timestamp(Timestamp)
An instant in time represented as the number of nanoseconds since the Unix epoch.
See [jiff::Timestamp].
Zoned(Zoned)
A time zone aware instant in time.
See [jiff::Zoned]
Date(Date)
A representation of a civil date in the Gregorian calendar.
See [jiff::civil::Date].
Time(Time)
A representation of civil “wall clock” time.
See [jiff::civil::Time].
DateTime(DateTime)
A representation of a civil datetime in the Gregorian calendar.
See [jiff::civil::DateTime].
Implementations§
§impl Value
impl Value
pub fn to_i8(&self) -> Option<i8>
pub fn to_i8(&self) -> Option<i8>
Attempts to convert this value to the target integer type.
Returns None if the value is not an integer variant or is out of
range for the target type. Conversion works across all integer
widths and signedness.
pub fn to_i8_unwrap(&self) -> i8
pub fn to_i8_unwrap(&self) -> i8
Converts this value to the target integer type, panicking on failure.
§Panics
Panics if the value is not an integer variant or is out of range.
pub fn to_i16(&self) -> Option<i16>
pub fn to_i16(&self) -> Option<i16>
Attempts to convert this value to the target integer type.
Returns None if the value is not an integer variant or is out of
range for the target type. Conversion works across all integer
widths and signedness.
pub fn to_i16_unwrap(&self) -> i16
pub fn to_i16_unwrap(&self) -> i16
Converts this value to the target integer type, panicking on failure.
§Panics
Panics if the value is not an integer variant or is out of range.
pub fn to_i32(&self) -> Option<i32>
pub fn to_i32(&self) -> Option<i32>
Attempts to convert this value to the target integer type.
Returns None if the value is not an integer variant or is out of
range for the target type. Conversion works across all integer
widths and signedness.
pub fn to_i32_unwrap(&self) -> i32
pub fn to_i32_unwrap(&self) -> i32
Converts this value to the target integer type, panicking on failure.
§Panics
Panics if the value is not an integer variant or is out of range.
pub fn to_i64(&self) -> Option<i64>
pub fn to_i64(&self) -> Option<i64>
Attempts to convert this value to the target integer type.
Returns None if the value is not an integer variant or is out of
range for the target type. Conversion works across all integer
widths and signedness.
pub fn to_i64_unwrap(&self) -> i64
pub fn to_i64_unwrap(&self) -> i64
Converts this value to the target integer type, panicking on failure.
§Panics
Panics if the value is not an integer variant or is out of range.
pub fn to_u8(&self) -> Option<u8>
pub fn to_u8(&self) -> Option<u8>
Attempts to convert this value to the target integer type.
Returns None if the value is not an integer variant or is out of
range for the target type. Conversion works across all integer
widths and signedness.
pub fn to_u8_unwrap(&self) -> u8
pub fn to_u8_unwrap(&self) -> u8
Converts this value to the target integer type, panicking on failure.
§Panics
Panics if the value is not an integer variant or is out of range.
pub fn to_u16(&self) -> Option<u16>
pub fn to_u16(&self) -> Option<u16>
Attempts to convert this value to the target integer type.
Returns None if the value is not an integer variant or is out of
range for the target type. Conversion works across all integer
widths and signedness.
pub fn to_u16_unwrap(&self) -> u16
pub fn to_u16_unwrap(&self) -> u16
Converts this value to the target integer type, panicking on failure.
§Panics
Panics if the value is not an integer variant or is out of range.
pub fn to_u32(&self) -> Option<u32>
pub fn to_u32(&self) -> Option<u32>
Attempts to convert this value to the target integer type.
Returns None if the value is not an integer variant or is out of
range for the target type. Conversion works across all integer
widths and signedness.
pub fn to_u32_unwrap(&self) -> u32
pub fn to_u32_unwrap(&self) -> u32
Converts this value to the target integer type, panicking on failure.
§Panics
Panics if the value is not an integer variant or is out of range.
pub fn to_u64(&self) -> Option<u64>
pub fn to_u64(&self) -> Option<u64>
Attempts to convert this value to the target integer type.
Returns None if the value is not an integer variant or is out of
range for the target type. Conversion works across all integer
widths and signedness.
pub fn to_u64_unwrap(&self) -> u64
pub fn to_u64_unwrap(&self) -> u64
Converts this value to the target integer type, panicking on failure.
§Panics
Panics if the value is not an integer variant or is out of range.
§impl Value
impl Value
pub fn empty_sparse_record() -> Value
pub fn empty_sparse_record() -> Value
Creates an empty Value::SparseRecord with no populated fields.
pub fn sparse_record(fields: PathFieldSet, record: ValueRecord) -> Value
pub fn sparse_record(fields: PathFieldSet, record: ValueRecord) -> Value
Creates a Value::SparseRecord by distributing values from record
into the positions specified by fields.
pub fn into_sparse_record(self) -> SparseRecord
pub fn into_sparse_record(self) -> SparseRecord
Consumes this value and returns the contained SparseRecord,
panicking if this is not a Value::SparseRecord.
§Panics
Panics if the value is not a SparseRecord variant.
§impl Value
impl Value
pub const fn is_null(&self) -> bool
pub const fn is_null(&self) -> bool
Returns true if this value is Value::Null.
§Examples
assert!(Value::Null.is_null());
assert!(!Value::from(1_i64).is_null());pub const fn is_record(&self) -> bool
pub const fn is_record(&self) -> bool
Returns true if this value is a Value::Record.
pub fn record_from_vec(fields: Vec<Value>) -> Value
pub fn record_from_vec(fields: Vec<Value>) -> Value
Creates a Value::Record from a vector of field values.
§Examples
let record = Value::record_from_vec(vec![Value::from(1_i64), Value::from("name")]);
assert!(record.is_record());pub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Returns the contained string slice if this is a Value::String,
or None otherwise.
pub fn as_string_unwrap(&self) -> &str
pub fn as_string_unwrap(&self) -> &str
Returns the contained string slice, panicking if this is not a
Value::String.
§Panics
Panics if the value is not a String variant.
pub fn as_record(&self) -> Option<&ValueRecord>
pub fn as_record(&self) -> Option<&ValueRecord>
Returns a reference to the contained ValueRecord if this is a
Value::Record, or None otherwise.
pub fn as_record_unwrap(&self) -> &ValueRecord
pub fn as_record_unwrap(&self) -> &ValueRecord
Returns a reference to the contained ValueRecord, panicking if
this is not a Value::Record.
§Panics
Panics if the value is not a Record variant.
pub fn as_record_mut_unwrap(&mut self) -> &mut ValueRecord
pub fn as_record_mut_unwrap(&mut self) -> &mut ValueRecord
Returns a mutable reference to the contained ValueRecord,
panicking if this is not a Value::Record.
§Panics
Panics if the value is not a Record variant.
pub fn into_record(self) -> ValueRecord
pub fn into_record(self) -> ValueRecord
Consumes this value and returns the contained ValueRecord,
panicking if this is not a Value::Record.
§Panics
Panics if the value is not a Record variant.
pub fn is_a(&self, ty: &Type) -> bool
pub fn is_a(&self, ty: &Type) -> bool
Returns true if this value is compatible with the given Type.
Null values are compatible with any type. For union types, the value must be compatible with at least one member type.
pub fn take(&mut self) -> Value
pub fn take(&mut self) -> Value
Takes the value out, replacing it with Value::Null.
§Examples
let mut v = Value::from(42_i64);
let taken = v.take();
assert_eq!(taken, 42_i64);
assert!(v.is_null());§impl Value
impl Value
pub fn list_from_vec(items: Vec<Value>) -> Value
pub fn list_from_vec(items: Vec<Value>) -> Value
Creates a Value::List from a vector of values.
§Examples
let list = Value::list_from_vec(vec![Value::from(1_i64), Value::from(2_i64)]);
assert!(list.is_list());pub fn is_list(&self) -> bool
pub fn is_list(&self) -> bool
Returns true if this value is a Value::List.
pub fn into_list_unwrap(self) -> Vec<Value>
pub fn into_list_unwrap(self) -> Vec<Value>
Consumes this value and returns the inner Vec<Value>, panicking
if this is not a Value::List.
§Panics
Panics if the value is not a List variant.
Trait Implementations§
§impl From<SparseRecord> for Value
impl From<SparseRecord> for Value
§fn from(value: SparseRecord) -> Value
fn from(value: SparseRecord) -> Value
§impl From<Value> for ValueStream
impl From<Value> for ValueStream
§fn from(src: Value) -> ValueStream
fn from(src: Value) -> ValueStream
§impl From<ValueRecord> for Value
impl From<ValueRecord> for Value
§fn from(value: ValueRecord) -> Value
fn from(value: ValueRecord) -> Value
§impl<T1, T2, T3> Like<(T1, T2, T3)> for Valuewhere
Value: Like<T1> + Like<T2> + Like<T3>,
impl<T1, T2, T3> Like<(T1, T2, T3)> for Valuewhere
Value: Like<T1> + Like<T2> + Like<T3>,
§fn like(&self, pattern: &(T1, T2, T3)) -> bool
fn like(&self, pattern: &(T1, T2, T3)) -> bool
§impl<T1, T2, T3, T4> Like<(T1, T2, T3, T4)> for Valuewhere
Value: Like<T1> + Like<T2> + Like<T3> + Like<T4>,
impl<T1, T2, T3, T4> Like<(T1, T2, T3, T4)> for Valuewhere
Value: Like<T1> + Like<T2> + Like<T3> + Like<T4>,
§fn like(&self, pattern: &(T1, T2, T3, T4)) -> bool
fn like(&self, pattern: &(T1, T2, T3, T4)) -> bool
§impl<T1, T2, T3, T4, T5> Like<(T1, T2, T3, T4, T5)> for Valuewhere
Value: Like<T1> + Like<T2> + Like<T3> + Like<T4> + Like<T5>,
impl<T1, T2, T3, T4, T5> Like<(T1, T2, T3, T4, T5)> for Valuewhere
Value: Like<T1> + Like<T2> + Like<T3> + Like<T4> + Like<T5>,
§fn like(&self, pattern: &(T1, T2, T3, T4, T5)) -> bool
fn like(&self, pattern: &(T1, T2, T3, T4, T5)) -> bool
§impl<T1, T2, T3, T4, T5, T6> Like<(T1, T2, T3, T4, T5, T6)> for Valuewhere
Value: Like<T1> + Like<T2> + Like<T3> + Like<T4> + Like<T5> + Like<T6>,
impl<T1, T2, T3, T4, T5, T6> Like<(T1, T2, T3, T4, T5, T6)> for Valuewhere
Value: Like<T1> + Like<T2> + Like<T3> + Like<T4> + Like<T5> + Like<T6>,
§fn like(&self, pattern: &(T1, T2, T3, T4, T5, T6)) -> bool
fn like(&self, pattern: &(T1, T2, T3, T4, T5, T6)) -> bool
§impl<T1, T2, T3, T4, T5, T6, T7> Like<(T1, T2, T3, T4, T5, T6, T7)> for Valuewhere
Value: Like<T1> + Like<T2> + Like<T3> + Like<T4> + Like<T5> + Like<T6> + Like<T7>,
impl<T1, T2, T3, T4, T5, T6, T7> Like<(T1, T2, T3, T4, T5, T6, T7)> for Valuewhere
Value: Like<T1> + Like<T2> + Like<T3> + Like<T4> + Like<T5> + Like<T6> + Like<T7>,
§fn like(&self, pattern: &(T1, T2, T3, T4, T5, T6, T7)) -> bool
fn like(&self, pattern: &(T1, T2, T3, T4, T5, T6, T7)) -> bool
§impl<T1, T2, T3, T4, T5, T6, T7, T8> Like<(T1, T2, T3, T4, T5, T6, T7, T8)> for Valuewhere
Value: Like<T1> + Like<T2> + Like<T3> + Like<T4> + Like<T5> + Like<T6> + Like<T7> + Like<T8>,
impl<T1, T2, T3, T4, T5, T6, T7, T8> Like<(T1, T2, T3, T4, T5, T6, T7, T8)> for Valuewhere
Value: Like<T1> + Like<T2> + Like<T3> + Like<T4> + Like<T5> + Like<T6> + Like<T7> + Like<T8>,
§fn like(&self, pattern: &(T1, T2, T3, T4, T5, T6, T7, T8)) -> bool
fn like(&self, pattern: &(T1, T2, T3, T4, T5, T6, T7, T8)) -> bool
§impl<T1, T2, T3, T4, T5, T6, T7, T8, T9> Like<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> for Valuewhere
Value: Like<T1> + Like<T2> + Like<T3> + Like<T4> + Like<T5> + Like<T6> + Like<T7> + Like<T8> + Like<T9>,
impl<T1, T2, T3, T4, T5, T6, T7, T8, T9> Like<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> for Valuewhere
Value: Like<T1> + Like<T2> + Like<T3> + Like<T4> + Like<T5> + Like<T6> + Like<T7> + Like<T8> + Like<T9>,
§fn like(&self, pattern: &(T1, T2, T3, T4, T5, T6, T7, T8, T9)) -> bool
fn like(&self, pattern: &(T1, T2, T3, T4, T5, T6, T7, T8, T9)) -> bool
§impl<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> Like<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> for Valuewhere
Value: Like<T1> + Like<T2> + Like<T3> + Like<T4> + Like<T5> + Like<T6> + Like<T7> + Like<T8> + Like<T9> + Like<T10>,
impl<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> Like<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> for Valuewhere
Value: Like<T1> + Like<T2> + Like<T3> + Like<T4> + Like<T5> + Like<T6> + Like<T7> + Like<T8> + Like<T9> + Like<T10>,
§fn like(&self, pattern: &(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)) -> bool
fn like(&self, pattern: &(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)) -> bool
§impl<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Like<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)> for Valuewhere
Value: Like<T1> + Like<T2> + Like<T3> + Like<T4> + Like<T5> + Like<T6> + Like<T7> + Like<T8> + Like<T9> + Like<T10> + Like<T11>,
impl<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Like<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)> for Valuewhere
Value: Like<T1> + Like<T2> + Like<T3> + Like<T4> + Like<T5> + Like<T6> + Like<T7> + Like<T8> + Like<T9> + Like<T10> + Like<T11>,
§fn like(&self, pattern: &(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)) -> bool
fn like(&self, pattern: &(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)) -> bool
§impl<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Like<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)> for Valuewhere
Value: Like<T1> + Like<T2> + Like<T3> + Like<T4> + Like<T5> + Like<T6> + Like<T7> + Like<T8> + Like<T9> + Like<T10> + Like<T11> + Like<T12>,
impl<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Like<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)> for Valuewhere
Value: Like<T1> + Like<T2> + Like<T3> + Like<T4> + Like<T5> + Like<T6> + Like<T7> + Like<T8> + Like<T9> + Like<T10> + Like<T11> + Like<T12>,
§fn like(
&self,
pattern: &(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12),
) -> bool
fn like( &self, pattern: &(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12), ) -> bool
§impl<T0, T1, T2> PartialEq<(T0, T1, T2)> for Value
impl<T0, T1, T2> PartialEq<(T0, T1, T2)> for Value
§impl<T0, T1, T2, T3> PartialEq<(T0, T1, T2, T3)> for Value
impl<T0, T1, T2, T3> PartialEq<(T0, T1, T2, T3)> for Value
§impl<T0, T1, T2, T3, T4> PartialEq<(T0, T1, T2, T3, T4)> for Value
impl<T0, T1, T2, T3, T4> PartialEq<(T0, T1, T2, T3, T4)> for Value
§impl<T0, T1, T2, T3, T4, T5> PartialEq<(T0, T1, T2, T3, T4, T5)> for Value
impl<T0, T1, T2, T3, T4, T5> PartialEq<(T0, T1, T2, T3, T4, T5)> for Value
§impl<T0, T1, T2, T3, T4, T5, T6> PartialEq<(T0, T1, T2, T3, T4, T5, T6)> for Value
impl<T0, T1, T2, T3, T4, T5, T6> PartialEq<(T0, T1, T2, T3, T4, T5, T6)> for Value
§impl<T0, T1, T2, T3, T4, T5, T6, T7> PartialEq<(T0, T1, T2, T3, T4, T5, T6, T7)> for Value
impl<T0, T1, T2, T3, T4, T5, T6, T7> PartialEq<(T0, T1, T2, T3, T4, T5, T6, T7)> for Value
§impl<T0, T1, T2, T3, T4, T5, T6, T7, T8> PartialEq<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> for Value
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8> PartialEq<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> for Value
§fn eq(&self, other: &(T0, T1, T2, T3, T4, T5, T6, T7, T8)) -> bool
fn eq(&self, other: &(T0, T1, T2, T3, T4, T5, T6, T7, T8)) -> bool
self and other values to be equal, and is used by ==.§impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> PartialEq<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> for Value
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> PartialEq<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> for Value
§fn eq(&self, other: &(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)) -> bool
fn eq(&self, other: &(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)) -> bool
self and other values to be equal, and is used by ==.§impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> PartialEq<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> for Value
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> PartialEq<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> for Value
§fn eq(&self, other: &(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)) -> bool
fn eq(&self, other: &(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)) -> bool
self and other values to be equal, and is used by ==.§impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> PartialEq<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)> for Value
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> PartialEq<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)> for Value
§fn eq(&self, other: &(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)) -> bool
fn eq(&self, other: &(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)) -> bool
self and other values to be equal, and is used by ==.§impl PartialOrd for Value
impl PartialOrd for Value
§fn partial_cmp(&self, other: &Value) -> Option<Ordering>
fn partial_cmp(&self, other: &Value) -> Option<Ordering>
Compares two values if they are of the same type.
Returns None for:
nullvalues (SQL semantics, e.g.,nullcomparisons are undefined)- Comparisons across different types
- Types without natural ordering (records, lists, etc.)
§impl Project for &Value
impl Project for &Value
§fn project(self, projection: &Projection) -> Option<Expr>
fn project(self, projection: &Projection) -> Option<Expr>
§impl Project for Value
impl Project for Value
§fn project(self, projection: &Projection) -> Option<Expr>
fn project(self, projection: &Projection) -> Option<Expr>
impl Eq for Value
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 UnwindSafe for Value
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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.