#[non_exhaustive]pub enum D1ArgumentValue {
Null,
Integer(i64),
Real(f64),
Text(String),
Blob(Vec<u8>),
}Expand description
One SQLite value on the Rust side of the JavaScript boundary, in either direction: a parameter a query binds, or a value a result row holds.
One type for both, as sqlx’s Any driver has, because both directions
are the same thing here – plain values that cross as JavaScript ones.
sqlx’s built-in drivers split them only because what they read is a C
handle or wire bytes, decoded lazily.
Owned rather than borrowed: sqlx 0.9’s Arguments has no lifetime, and the
backends return a whole result set as JavaScript values, leaving nothing on
the Rust side for a row to borrow from.
Non-exhaustive so that a backend growing a representation – a BigInt,
say – is not a breaking change for Encode impls outside this crate.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Null
SQL NULL: JavaScript null.
Integer(i64)
A whole number, within ±(2^53 − 1) because it crosses as a JavaScript
number and not a BigInt. A result only holds integers in that range;
binding a wider one is an encode error rather than a rounded value.
Real(f64)
Any other number, stored as REAL.
Text(String)
A JavaScript string, stored as TEXT.
Blob(Vec<u8>)
An ArrayBuffer, stored as BLOB.
Implementations§
Source§impl Value
impl Value
Sourcepub fn from_number(value: f64) -> Value
pub fn from_number(value: f64) -> Value
A JavaScript number, as the storage class it most likely came from.
JavaScript has one number type, so 3 and 3.0 arrive the same. A
whole number in the safe range is taken as an Integer – which is
why f64 decodes from Integer as well as Real. Anything else,
including whole numbers too large to be exact, is a Real.
Trait Implementations§
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<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> 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 more