pub enum QueryBuilderValue {
Show 25 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>>>),
ChronoDate(Option<Box<NaiveDate>>),
ChronoTime(Option<Box<NaiveTime>>),
ChronoDateTime(Option<Box<NaiveDateTime>>),
ChronoDateTimeUtc(Option<Box<DateTime<Utc>>>),
ChronoDateTimeLocal(Option<Box<DateTime<Local>>>),
ChronoDateTimeWithTimeZone(Option<Box<DateTime<FixedOffset>>>),
Uuid(Option<Box<Uuid>>),
Json(Option<Box<Value>>),
Decimal(Option<Box<Decimal>>),
BigDecimal(Option<Box<BigDecimal>>),
Array(ArrayType, Option<Box<Vec<Value>>>),
}database and non-WebAssembly only.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)
ChronoDate(Option<Box<NaiveDate>>)
with-chrono only.Chrono NaiveDate
ChronoTime(Option<Box<NaiveTime>>)
with-chrono only.Chrono NaiveTime
ChronoDateTime(Option<Box<NaiveDateTime>>)
with-chrono only.Chrono NaiveDateTime
ChronoDateTimeUtc(Option<Box<DateTime<Utc>>>)
with-chrono only.Chrono DateTime with UTC timezone
ChronoDateTimeLocal(Option<Box<DateTime<Local>>>)
with-chrono only.Chrono DateTime with Local timezone
ChronoDateTimeWithTimeZone(Option<Box<DateTime<FixedOffset>>>)
with-chrono only.Chrono DateTime with fixed offset timezone
Uuid(Option<Box<Uuid>>)
with-uuid only.UUID value
Json(Option<Box<Value>>)
with-json only.JSON value
Decimal(Option<Box<Decimal>>)
with-rust_decimal only.Rust Decimal value
BigDecimal(Option<Box<BigDecimal>>)
with-bigdecimal only.BigDecimal value
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'"
);Trait Implementations§
Source§impl From<BigDecimal> for Value
Available on crate feature with-bigdecimal only.
impl From<BigDecimal> for Value
with-bigdecimal only.Source§fn from(v: BigDecimal) -> Value
fn from(v: BigDecimal) -> Value
Source§impl From<NaiveDateTime> for Value
Available on crate feature with-chrono only.
impl From<NaiveDateTime> for Value
with-chrono only.Source§fn from(v: NaiveDateTime) -> Value
fn from(v: NaiveDateTime) -> Value
Source§impl From<Value> for SimpleExpr
impl From<Value> for SimpleExpr
Source§fn from(v: Value) -> SimpleExpr
fn from(v: Value) -> SimpleExpr
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<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = Infallible
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().Source§impl<E> ServerFnErrorAssertions<E> for Ewhere
E: Debug,
impl<E> ServerFnErrorAssertions<E> for Ewhere
E: Debug,
Source§fn should_contain_message(&self, expected: &str)where
E: Display,
fn should_contain_message(&self, expected: &str)where
E: Display,
Source§fn should_have_message(&self, expected: &str)where
E: Display,
fn should_have_message(&self, expected: &str)where
E: Display,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.