pub enum PostgresValue<'a> {
Smallint(i16),
Integer(i32),
Bigint(i64),
Real(f32),
DoublePrecision(f64),
Text(Cow<'a, str>),
Bytea(Cow<'a, [u8]>),
Boolean(bool),
Enum(Box<dyn PostgresEnum>),
Array(Vec<Self>),
Null,
}Expand description
One PostgreSQL value, borrowed for 'a: a bound parameter or a decoded column.
Rust values convert into it with From (42_i32.into()), and it converts
back with convert or TryFrom. Variants for optional
crates (chrono, uuid, …) exist only with the matching feature.
§Examples
use drizzle_postgres::values::PostgresValue;
// Integer conversion
let int_val: PostgresValue<'_> = 42i32.into();
assert!(matches!(int_val, PostgresValue::Integer(42)));
// String conversion
let str_val: PostgresValue<'_> = "hello".into();
assert!(matches!(str_val, PostgresValue::Text(_)));
// Boolean conversion
let bool_val: PostgresValue<'_> = true.into();
assert!(matches!(bool_val, PostgresValue::Boolean(true)));Variants§
Smallint(i16)
SMALLINT values (16-bit signed integer)
Integer(i32)
INTEGER values (32-bit signed integer)
Bigint(i64)
BIGINT values (64-bit signed integer)
Real(f32)
REAL values (32-bit floating point)
DoublePrecision(f64)
DOUBLE PRECISION values (64-bit floating point)
Text(Cow<'a, str>)
TEXT, VARCHAR, CHAR values
Bytea(Cow<'a, [u8]>)
BYTEA values (binary data)
Boolean(bool)
BOOLEAN values
Enum(Box<dyn PostgresEnum>)
Native PostgreSQL ENUM values
Array(Vec<Self>)
Array of any PostgreSQL type
Null
NULL value
Implementations§
Source§impl PostgresValue<'_>
impl PostgresValue<'_>
Sourcepub fn as_enum(&self) -> Option<&dyn PostgresEnum>
pub fn as_enum(&self) -> Option<&dyn PostgresEnum>
Returns the enum value if this is a PostgreSQL enum.
Sourcepub fn into_owned(self) -> OwnedPostgresValue
pub fn into_owned(self) -> OwnedPostgresValue
Converts the value into an OwnedPostgresValue, copying borrowed data.
Sourcepub fn convert<T: FromPostgresValue>(self) -> Result<T, DrizzleError>
pub fn convert<T: FromPostgresValue>(self) -> Result<T, DrizzleError>
Converts the value into a Rust type through FromPostgresValue.
Integers convert to other integer types when they fit, and text is
parsed for numeric targets. An enum converts through its variant label
and NUMERIC through its text form.
§Examples
use drizzle_postgres::values::PostgresValue;
let value = PostgresValue::Integer(7);
let n: i64 = value.convert().unwrap();
assert_eq!(n, 7);§Errors
Returns DrizzleError::ConversionError when T cannot hold the
stored value, for example text that does not parse as the integer type.
Sourcepub fn convert_ref<T: FromPostgresValue>(&self) -> Result<T, DrizzleError>
pub fn convert_ref<T: FromPostgresValue>(&self) -> Result<T, DrizzleError>
Like convert, but borrows the value (cloning data
where T needs it).
§Errors
Returns DrizzleError::ConversionError when T cannot hold the
stored value.
Trait Implementations§
Source§impl<'a> Clone for PostgresValue<'a>
impl<'a> Clone for PostgresValue<'a>
Source§impl<'a> Debug for PostgresValue<'a>
impl<'a> Debug for PostgresValue<'a>
Source§impl<'a> Default for PostgresValue<'a>
impl<'a> Default for PostgresValue<'a>
Source§impl Display for PostgresValue<'_>
impl Display for PostgresValue<'_>
Source§impl<'a, S, State, T, M, R, G> Expr<'a, PostgresValue<'a>> for SelectBuilder<'a, S, State, T, M, R, G>
impl<'a, S, State, T, M, R, G> Expr<'a, PostgresValue<'a>> for SelectBuilder<'a, S, State, T, M, R, G>
Source§type SQLType = <M as SubqueryType<'a, PostgresValue<'a>>>::SQLType
type SQLType = <M as SubqueryType<'a, PostgresValue<'a>>>::SQLType
Source§fn to_expr_sql(&self) -> SQL<'a, V>
fn to_expr_sql(&self) -> SQL<'a, V>
Source§fn into_expr_sql(self) -> SQL<'a, V>where
Self: Sized,
fn into_expr_sql(self) -> SQL<'a, V>where
Self: Sized,
Source§fn to_condition_sql(&self) -> Option<SQL<'a, V>>
fn to_condition_sql(&self) -> Option<SQL<'a, V>>
ConditionList. Read moreSource§fn into_condition_sql(self) -> Option<SQL<'a, V>>where
Self: Sized,
fn into_condition_sql(self) -> Option<SQL<'a, V>>where
Self: Sized,
Expr::to_condition_sql.Source§impl<'a, T> Expr<'a, PostgresValue<'a>> for PgArray<T>
impl<'a, T> Expr<'a, PostgresValue<'a>> for PgArray<T>
Source§type SQLType = Array<<T as Expr<'a, PostgresValue<'a>>>::SQLType>
type SQLType = Array<<T as Expr<'a, PostgresValue<'a>>>::SQLType>
Source§fn to_expr_sql(&self) -> SQL<'a, V>
fn to_expr_sql(&self) -> SQL<'a, V>
Source§fn into_expr_sql(self) -> SQL<'a, V>where
Self: Sized,
fn into_expr_sql(self) -> SQL<'a, V>where
Self: Sized,
Source§fn to_condition_sql(&self) -> Option<SQL<'a, V>>
fn to_condition_sql(&self) -> Option<SQL<'a, V>>
ConditionList. Read moreSource§fn into_condition_sql(self) -> Option<SQL<'a, V>>where
Self: Sized,
fn into_condition_sql(self) -> Option<SQL<'a, V>>where
Self: Sized,
Expr::to_condition_sql.Source§impl<'a> From<&'a OwnedPostgresValue> for PostgresValue<'a>
impl<'a> From<&'a OwnedPostgresValue> for PostgresValue<'a>
Source§fn from(value: &'a OwnedPostgresValue) -> Self
fn from(value: &'a OwnedPostgresValue) -> Self
Source§impl<'a> From<&'a PostgresValue<'a>> for Cow<'a, PostgresValue<'a>>
impl<'a> From<&'a PostgresValue<'a>> for Cow<'a, PostgresValue<'a>>
Source§fn from(value: &'a PostgresValue<'a>) -> Self
fn from(value: &'a PostgresValue<'a>) -> Self
Source§impl<'a> From<&'a String> for PostgresValue<'a>
impl<'a> From<&'a String> for PostgresValue<'a>
Source§impl<'a> From<&'a [PostgresValue<'a>]> for PostgresValue<'a>
impl<'a> From<&'a [PostgresValue<'a>]> for PostgresValue<'a>
Source§impl<'a> From<&'a [u8]> for PostgresValue<'a>
impl<'a> From<&'a [u8]> for PostgresValue<'a>
Source§impl<'a> From<&'a bool> for PostgresValue<'a>
impl<'a> From<&'a bool> for PostgresValue<'a>
Source§impl<'a> From<&'a f32> for PostgresValue<'a>
impl<'a> From<&'a f32> for PostgresValue<'a>
Source§impl<'a> From<&'a f64> for PostgresValue<'a>
impl<'a> From<&'a f64> for PostgresValue<'a>
Source§impl<'a> From<&'a i8> for PostgresValue<'a>
impl<'a> From<&'a i8> for PostgresValue<'a>
Source§impl<'a> From<&'a i16> for PostgresValue<'a>
impl<'a> From<&'a i16> for PostgresValue<'a>
Source§impl<'a> From<&'a i32> for PostgresValue<'a>
impl<'a> From<&'a i32> for PostgresValue<'a>
Source§impl<'a> From<&'a i64> for PostgresValue<'a>
impl<'a> From<&'a i64> for PostgresValue<'a>
Source§impl<'a> From<&'a isize> for PostgresValue<'a>
impl<'a> From<&'a isize> for PostgresValue<'a>
Source§impl<'a> From<&'a str> for PostgresValue<'a>
impl<'a> From<&'a str> for PostgresValue<'a>
Source§impl<'a> From<&'a u8> for PostgresValue<'a>
impl<'a> From<&'a u8> for PostgresValue<'a>
Source§impl<'a> From<&'a u16> for PostgresValue<'a>
impl<'a> From<&'a u16> for PostgresValue<'a>
Source§impl<'a> From<&'a u32> for PostgresValue<'a>
impl<'a> From<&'a u32> for PostgresValue<'a>
Source§impl<'a> From<&'a u64> for PostgresValue<'a>
impl<'a> From<&'a u64> for PostgresValue<'a>
Source§impl<'a> From<&'a usize> for PostgresValue<'a>
impl<'a> From<&'a usize> for PostgresValue<'a>
Source§impl<'a> From<&PostgresValue<'a>> for OwnedPostgresValue
impl<'a> From<&PostgresValue<'a>> for OwnedPostgresValue
Source§fn from(value: &PostgresValue<'a>) -> Self
fn from(value: &PostgresValue<'a>) -> Self
Source§impl<T> From<Option<T>> for PostgresValue<'_>where
T: TryInto<Self>,
None is NULL.
impl<T> From<Option<T>> for PostgresValue<'_>where
T: TryInto<Self>,
None is NULL.
§Panics
Panics when T’s conversion fails (for example a JSON payload whose
Serialize implementation errors), rather than storing NULL in place of
the value.
Source§impl From<OwnedPostgresValue> for PostgresValue<'_>
impl From<OwnedPostgresValue> for PostgresValue<'_>
Source§fn from(value: OwnedPostgresValue) -> Self
fn from(value: OwnedPostgresValue) -> Self
Source§impl<'a> From<PostgresValue<'a>> for OwnedPostgresValue
impl<'a> From<PostgresValue<'a>> for OwnedPostgresValue
Source§fn from(value: PostgresValue<'a>) -> Self
fn from(value: PostgresValue<'a>) -> Self
Source§impl<'a> From<PostgresValue<'a>> for SQL<'a, PostgresValue<'a>>
impl<'a> From<PostgresValue<'a>> for SQL<'a, PostgresValue<'a>>
Source§fn from(value: PostgresValue<'a>) -> Self
fn from(value: PostgresValue<'a>) -> Self
Source§impl<'a> From<PostgresValue<'a>> for Cow<'a, PostgresValue<'a>>
impl<'a> From<PostgresValue<'a>> for Cow<'a, PostgresValue<'a>>
Source§fn from(value: PostgresValue<'a>) -> Self
fn from(value: PostgresValue<'a>) -> Self
Source§impl From<String> for PostgresValue<'_>
impl From<String> for PostgresValue<'_>
Source§impl<'a, T> From<T> for PostgresValue<'a>where
T: DrizzlePostgresColumn,
impl<'a, T> From<T> for PostgresValue<'a>where
T: DrizzlePostgresColumn,
Source§impl From<Vec<PostgresValue<'_>>> for PostgresValue<'_>
impl From<Vec<PostgresValue<'_>>> for PostgresValue<'_>
Source§impl From<bool> for PostgresValue<'_>
impl From<bool> for PostgresValue<'_>
Source§impl From<f32> for PostgresValue<'_>
impl From<f32> for PostgresValue<'_>
Source§impl From<f64> for PostgresValue<'_>
impl From<f64> for PostgresValue<'_>
Source§impl From<i8> for PostgresValue<'_>
impl From<i8> for PostgresValue<'_>
Source§impl From<i16> for PostgresValue<'_>
impl From<i16> for PostgresValue<'_>
Source§impl From<i32> for PostgresValue<'_>
impl From<i32> for PostgresValue<'_>
Source§impl From<i64> for PostgresValue<'_>
impl From<i64> for PostgresValue<'_>
Source§impl From<isize> for PostgresValue<'_>
impl From<isize> for PostgresValue<'_>
Source§impl From<u8> for PostgresValue<'_>
impl From<u8> for PostgresValue<'_>
Source§impl From<u16> for PostgresValue<'_>
impl From<u16> for PostgresValue<'_>
Source§impl From<u32> for PostgresValue<'_>
impl From<u32> for PostgresValue<'_>
Source§impl From<u64> for PostgresValue<'_>
impl From<u64> for PostgresValue<'_>
Source§impl From<usize> for PostgresValue<'_>
impl From<usize> for PostgresValue<'_>
Source§impl<'a> PartialEq for PostgresValue<'a>
impl<'a> PartialEq for PostgresValue<'a>
Source§impl SQLParam for PostgresValue<'_>
impl SQLParam for PostgresValue<'_>
Source§fn pagination_param(value: usize) -> Option<Self>
fn pagination_param(value: usize) -> Option<Self>
Binds LIMIT/OFFSET values as BIGINT parameters so paginated queries
share one SQL text (and one cached prepared statement) across pages.
impl<'a> StructuralPartialEq for PostgresValue<'a>
Source§impl<'a, State> ToSQL<'a, PostgresValue<'a>> for RefreshMaterializedView<'a, State>
impl<'a, State> ToSQL<'a, PostgresValue<'a>> for RefreshMaterializedView<'a, State>
Source§impl<'a, Schema, State, Table, Marker, Row, Grouped> ToSQL<'a, PostgresValue<'a>> for QueryBuilder<'a, Schema, State, Table, Marker, Row, Grouped>
impl<'a, Schema, State, Table, Marker, Row, Grouped> ToSQL<'a, PostgresValue<'a>> for QueryBuilder<'a, Schema, State, Table, Marker, Row, Grouped>
Source§impl<'a, T> ToSQL<'a, PostgresValue<'a>> for PgArray<T>
impl<'a, T> ToSQL<'a, PostgresValue<'a>> for PgArray<T>
Source§impl<'a> TryFrom<&'a PostgresValue<'a>> for &'a str
impl<'a> TryFrom<&'a PostgresValue<'a>> for &'a str
Source§type Error = DrizzleError
type Error = DrizzleError
Source§impl<'a> TryFrom<&'a PostgresValue<'a>> for &'a [u8]
impl<'a> TryFrom<&'a PostgresValue<'a>> for &'a [u8]
Source§type Error = DrizzleError
type Error = DrizzleError
Source§impl<'a> TryFrom<&'a PostgresValue<'a>> for &'a [PostgresValue<'a>]
impl<'a> TryFrom<&'a PostgresValue<'a>> for &'a [PostgresValue<'a>]
Source§type Error = DrizzleError
type Error = DrizzleError
Source§impl<'a> TryFrom<PostgresValue<'a>> for i16
impl<'a> TryFrom<PostgresValue<'a>> for i16
Source§type Error = DrizzleError
type Error = DrizzleError
Source§impl<'a> TryFrom<PostgresValue<'a>> for i32
impl<'a> TryFrom<PostgresValue<'a>> for i32
Source§type Error = DrizzleError
type Error = DrizzleError
Source§impl<'a> TryFrom<PostgresValue<'a>> for i64
impl<'a> TryFrom<PostgresValue<'a>> for i64
Source§type Error = DrizzleError
type Error = DrizzleError
Source§impl<'a> TryFrom<PostgresValue<'a>> for f32
impl<'a> TryFrom<PostgresValue<'a>> for f32
Source§type Error = DrizzleError
type Error = DrizzleError
Source§impl<'a> TryFrom<PostgresValue<'a>> for f64
impl<'a> TryFrom<PostgresValue<'a>> for f64
Source§type Error = DrizzleError
type Error = DrizzleError
Source§impl<'a> TryFrom<PostgresValue<'a>> for bool
impl<'a> TryFrom<PostgresValue<'a>> for bool
Source§type Error = DrizzleError
type Error = DrizzleError
Source§impl<'a> TryFrom<PostgresValue<'a>> for String
impl<'a> TryFrom<PostgresValue<'a>> for String
Source§type Error = DrizzleError
type Error = DrizzleError
Source§impl<'a> TryFrom<PostgresValue<'a>> for Box<String>
impl<'a> TryFrom<PostgresValue<'a>> for Box<String>
Source§type Error = DrizzleError
type Error = DrizzleError
Source§impl<'a> TryFrom<PostgresValue<'a>> for Rc<String>
impl<'a> TryFrom<PostgresValue<'a>> for Rc<String>
Source§type Error = DrizzleError
type Error = DrizzleError
Source§impl<'a> TryFrom<PostgresValue<'a>> for Arc<String>
impl<'a> TryFrom<PostgresValue<'a>> for Arc<String>
Source§type Error = DrizzleError
type Error = DrizzleError
Source§impl<'a> TryFrom<PostgresValue<'a>> for Box<str>
impl<'a> TryFrom<PostgresValue<'a>> for Box<str>
Source§type Error = DrizzleError
type Error = DrizzleError
Source§impl<'a> TryFrom<PostgresValue<'a>> for Rc<str>
impl<'a> TryFrom<PostgresValue<'a>> for Rc<str>
Source§type Error = DrizzleError
type Error = DrizzleError
Source§impl<'a> TryFrom<PostgresValue<'a>> for Arc<str>
impl<'a> TryFrom<PostgresValue<'a>> for Arc<str>
Source§type Error = DrizzleError
type Error = DrizzleError
Source§impl<'a> TryFrom<PostgresValue<'a>> for Vec<u8>
impl<'a> TryFrom<PostgresValue<'a>> for Vec<u8>
Source§type Error = DrizzleError
type Error = DrizzleError
Source§impl<'a> TryFrom<PostgresValue<'a>> for Box<Vec<u8>>
impl<'a> TryFrom<PostgresValue<'a>> for Box<Vec<u8>>
Source§type Error = DrizzleError
type Error = DrizzleError
Source§impl<'a> TryFrom<PostgresValue<'a>> for Rc<Vec<u8>>
impl<'a> TryFrom<PostgresValue<'a>> for Rc<Vec<u8>>
Source§type Error = DrizzleError
type Error = DrizzleError
Source§impl<'a> TryFrom<PostgresValue<'a>> for Arc<Vec<u8>>
impl<'a> TryFrom<PostgresValue<'a>> for Arc<Vec<u8>>
Source§type Error = DrizzleError
type Error = DrizzleError
Source§impl<'a> TryFrom<PostgresValue<'a>> for Vec<PostgresValue<'a>>
impl<'a> TryFrom<PostgresValue<'a>> for Vec<PostgresValue<'a>>
Source§type Error = DrizzleError
type Error = DrizzleError
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for PostgresValue<'a>
impl<'a> !UnwindSafe for PostgresValue<'a>
impl<'a> Freeze for PostgresValue<'a>
impl<'a> Send for PostgresValue<'a>
impl<'a> Sync for PostgresValue<'a>
impl<'a> Unpin for PostgresValue<'a>
impl<'a> UnsafeUnpin for PostgresValue<'a>
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<Joined, From> JoinKey<From, JoinReverse> for Joined
impl<Joined, From> JoinKey<From, JoinReverse> for Joined
impl<List> ListIncludes<Nil, ()> for List
impl<Mk> MarkerAggValidFor<()> for Mk
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more