Enum PgParam
#[non_exhaustive]pub enum PgParam {
Text(Option<String>),
Int8(Option<i64>),
Int4(Option<i32>),
Bool(Option<bool>),
Float8(Option<f64>),
Bytea(Option<Vec<u8>>),
}projection-store only.Expand description
One bound parameter, owned.
sqlx ships no owned dynamic bind value. PgArguments is written through the
Arguments trait’s add, which is fallible, and
probe_write is not — so
encoding at push would have to park an impossible failure in the batch and
report it at commit, adding a state and an error variant to represent
something that cannot happen for these types. Parameters are therefore kept
as values and bound at replay.
§Why every variant carries an Option rather than there being one Null
Postgres parameters are typed, and sqlx derives the type OID from the Rust
type at bind. A single untyped Null variant would force this module to
pick a concrete None::<T> at replay, and None::<i64> against a text
column is a server-side type error rather than a silent success. A null with
a type is Postgres’ own model, so it is this enum’s model too.
The name is PgParam and not PgValue because sqlx::postgres::PgValue
exists and is public — on the decode side. Nothing here would fail to
compile; a reader tracking down which PgValue a line meant would lose the
time this name saves.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Text(Option<String>)
text.
Int8(Option<i64>)
bigint.
Int4(Option<i32>)
integer.
Bool(Option<bool>)
boolean.
Float8(Option<f64>)
double precision.
Bytea(Option<Vec<u8>>)
bytea.
Implementations§
Trait Implementations§
impl StructuralPartialEq for PgParam
Auto Trait Implementations§
impl Freeze for PgParam
impl RefUnwindSafe for PgParam
impl Send for PgParam
impl Sync for PgParam
impl Unpin for PgParam
impl UnsafeUnpin for PgParam
impl UnwindSafe for PgParam
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
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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