pub enum Value {
Show 15 variants
Bool(Option<bool>),
TinyInt(Option<i8>),
SmallInt(Option<i16>),
Int(Option<i32>),
BigInt(Option<i64>),
TinyUnsigned(Option<u8>),
SmallUnsigned(Option<u16>),
Unsigned(Option<u32>),
BigUnsigned(Option<u64>),
Float(Option<f32>),
Double(Option<f64>),
Char(Option<char>),
String(Option<Box<String>>),
Bytes(Option<Box<Vec<u8>>>),
Array(ArrayType, Option<Box<Vec<Value>>>),
}Expand description
Core value representation for SQL parameters.
This enum represents all possible SQL value types. The enum is designed to be size-optimized: larger types are boxed to maintain a consistent enum size of approximately one pointer width.
§Null Values
All variants use Option<T> to represent nullable values. A None value
will be rendered as SQL NULL.
§Variant Naming Convention
Variant names align with common SQL type names:
| Variant | SQL Type | Rust Type |
|---|---|---|
Value::Bool | BOOLEAN | bool |
Value::TinyInt | TINYINT | i8 |
Value::SmallInt | SMALLINT | i16 |
Value::Int | INTEGER | i32 |
Value::BigInt | BIGINT | i64 |
Value::TinyUnsigned | TINYINT UNSIGNED | u8 |
Value::SmallUnsigned | SMALLINT UNSIGNED | u16 |
Value::Unsigned | INTEGER UNSIGNED | u32 |
Value::BigUnsigned | BIGINT UNSIGNED | u64 |
Value::Float | FLOAT | f32 |
Value::Double | DOUBLE | f64 |
Value::Char | CHAR | char |
Value::String | VARCHAR/TEXT | String |
Value::Bytes | BLOB/BINARY | Vec<u8> |
§Example
use reinhardt_query::Value;
// Integer types
let int_val = Value::Int(Some(42));
let null_int = Value::Int(None);
let bigint_val = Value::BigInt(Some(9223372036854775807i64));
// String type (boxed for size optimization)
let string_val = Value::String(Some(Box::new("hello".to_string())));
// Check for null
assert!(!int_val.is_null());
assert!(null_int.is_null());
// Convert to SQL literal
assert_eq!(int_val.to_sql_literal(), "42");
assert_eq!(null_int.to_sql_literal(), "NULL");§Feature-Gated Types
Additional types are available with feature flags:
with-chrono: Date/time types (Value::ChronoDate,Value::ChronoTime, etc.)with-uuid: UUID type (Value::Uuid)with-json: JSON type (Value::Json)with-rust_decimal: Decimal type (Value::Decimal)with-bigdecimal: BigDecimal type (Value::BigDecimal)
Variants§
Bool(Option<bool>)
Boolean value
TinyInt(Option<i8>)
8-bit signed integer
SmallInt(Option<i16>)
16-bit signed integer
Int(Option<i32>)
32-bit signed integer
BigInt(Option<i64>)
64-bit signed integer
TinyUnsigned(Option<u8>)
8-bit unsigned integer
SmallUnsigned(Option<u16>)
16-bit unsigned integer
Unsigned(Option<u32>)
32-bit unsigned integer
BigUnsigned(Option<u64>)
64-bit unsigned integer
Float(Option<f32>)
32-bit floating point
Double(Option<f64>)
64-bit floating point
Char(Option<char>)
Single character
String(Option<Box<String>>)
String value (boxed)
Bytes(Option<Box<Vec<u8>>>)
Binary data (boxed)
Array(ArrayType, Option<Box<Vec<Value>>>)
Array of values with element type information
Implementations§
Source§impl Value
impl Value
Sourcepub fn to_sql_literal(&self) -> String
pub fn to_sql_literal(&self) -> String
Convert this value to a SQL literal string suitable for inlining into a SQL statement.
This is used by QueryStatementBuilder::to_string() to produce
SQL with values inlined (for debugging and non-parameterized use).
§Example
use reinhardt_query::Value;
assert_eq!(Value::Int(Some(42)).to_sql_literal(), "42");
assert_eq!(Value::Int(None).to_sql_literal(), "NULL");
assert_eq!(
Value::String(Some(Box::new("hello".to_string()))).to_sql_literal(),
"'hello'"
);
assert_eq!(
Value::String(Some(Box::new("it's".to_string()))).to_sql_literal(),
"'it''s'"
);