pub enum DbValue {
}Expand description
A backend-neutral parameter value.
Construct variants directly, or use the From conversions for ergonomics —
including Option<T>, which maps None to DbValue::Null:
use dbkit::DbValue;
let a: DbValue = 42i64.into(); // Int(42)
let b: DbValue = "hello".into(); // Text("hello")
let c: DbValue = Some(3.5f64).into(); // Float(3.5)
let d: DbValue = None::<i64>.into(); // Null
assert_eq!(d, DbValue::Null);Variants§
Null
SQL NULL.
Bool(bool)
Boolean.
Int(i64)
Signed 64-bit integer. Smaller integer types widen into this.
Float(f64)
64-bit floating point.
Text(String)
UTF-8 text.
Bytes(Vec<u8>)
Raw bytes (BYTEA / BLOB).
Date(NaiveDate)
SQL DATE.
DateTime(NaiveDateTime)
SQL TIMESTAMP (no time zone).
TimestampTz(DateTime<Utc>)
SQL TIMESTAMPTZ (UTC).
Json(JsonValue)
SQL JSON / JSONB.
Uuid(Uuid)
SQL UUID.
Time(NaiveTime)
SQL TIME (no time zone).
TextArray(Vec<String>)
SQL TEXT[].
FloatArray(Vec<f64>)
SQL FLOAT8[] (double precision array).
OptFloatArray(Vec<Option<f64>>)
SQL FLOAT8[] with nullable elements.
Trait Implementations§
Source§impl From<NaiveDateTime> for DbValue
Available on crate feature postgres-native only.
impl From<NaiveDateTime> for DbValue
Available on crate feature
postgres-native only.Source§fn from(v: NaiveDateTime) -> Self
fn from(v: NaiveDateTime) -> Self
Converts to this type from the input type.
Source§impl<T: Into<DbValue>> From<Option<T>> for DbValue
None becomes DbValue::Null; Some(x) delegates to x’s conversion.
impl<T: Into<DbValue>> From<Option<T>> for DbValue
None becomes DbValue::Null; Some(x) delegates to x’s conversion.
impl StructuralPartialEq for DbValue
Auto Trait Implementations§
impl Freeze for DbValue
impl RefUnwindSafe for DbValue
impl Send for DbValue
impl Sync for DbValue
impl Unpin for DbValue
impl UnsafeUnpin for DbValue
impl UnwindSafe for DbValue
Blanket Implementations§
impl<T> Allocation for T
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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 more