pub enum Value<'a> {
Show 17 variants
Int32(Option<i32>),
Int64(Option<i64>),
Float(Option<f32>),
Double(Option<f64>),
Text(Option<Cow<'a, str>>),
Enum(Option<Cow<'a, str>>),
Bytes(Option<Cow<'a, [u8]>>),
Boolean(Option<bool>),
Char(Option<char>),
Array(Option<Vec<Value<'a>>>),
Numeric(Option<BigDecimal>),
Json(Option<Value>),
Xml(Option<Cow<'a, str>>),
Uuid(Option<Uuid>),
DateTime(Option<DateTime<Utc>>),
Date(Option<NaiveDate>),
Time(Option<NaiveTime>),
}
Expand description
A value we must parameterize for the prepared statement. Null values should be
defined by their corresponding type variants with a None
value for best
compatibility.
Variants§
Int32(Option<i32>)
32-bit signed integer.
Int64(Option<i64>)
64-bit signed integer.
Float(Option<f32>)
32-bit floating point.
Double(Option<f64>)
64-bit floating point.
Text(Option<Cow<'a, str>>)
String value.
Enum(Option<Cow<'a, str>>)
Database enum value.
Bytes(Option<Cow<'a, [u8]>>)
Bytes value.
Boolean(Option<bool>)
Boolean value.
Char(Option<char>)
A single character.
Array(Option<Vec<Value<'a>>>)
An array value (PostgreSQL).
Numeric(Option<BigDecimal>)
bigdecimal
only.A numeric value.
Json(Option<Value>)
json
only.A JSON value.
Xml(Option<Cow<'a, str>>)
A XML value.
Uuid(Option<Uuid>)
uuid
only.An UUID value.
DateTime(Option<DateTime<Utc>>)
chrono
only.A datetime value.
Date(Option<NaiveDate>)
chrono
only.A date value.
Time(Option<NaiveTime>)
chrono
only.A time value.
Implementations§
source§impl<'a> Value<'a>
impl<'a> Value<'a>
sourcepub const fn numeric(value: BigDecimal) -> Self
Available on crate feature bigdecimal
only.
pub const fn numeric(value: BigDecimal) -> Self
bigdecimal
only.Creates a new decimal value.
sourcepub fn enum_variant<T>(value: T) -> Selfwhere
T: Into<Cow<'a, str>>,
pub fn enum_variant<T>(value: T) -> Selfwhere T: Into<Cow<'a, str>>,
Creates a new enum value.
sourcepub fn array<I, V>(value: I) -> Selfwhere
I: IntoIterator<Item = V>,
V: Into<Value<'a>>,
pub fn array<I, V>(value: I) -> Selfwhere I: IntoIterator<Item = V>, V: Into<Value<'a>>,
Creates a new array value.
sourcepub const fn uuid(value: Uuid) -> Self
Available on crate feature uuid
only.
pub const fn uuid(value: Uuid) -> Self
uuid
only.Creates a new uuid value.
sourcepub const fn datetime(value: DateTime<Utc>) -> Self
Available on crate feature chrono
only.
pub const fn datetime(value: DateTime<Utc>) -> Self
chrono
only.Creates a new datetime value.
sourcepub const fn date(value: NaiveDate) -> Self
Available on crate feature chrono
only.
pub const fn date(value: NaiveDate) -> Self
chrono
only.Creates a new date value.
sourcepub const fn time(value: NaiveTime) -> Self
Available on crate feature chrono
only.
pub const fn time(value: NaiveTime) -> Self
chrono
only.Creates a new time value.
sourcepub const fn json(value: Value) -> Self
Available on crate feature json
only.
pub const fn json(value: Value) -> Self
json
only.Creates a new JSON value.
sourcepub const fn as_char(&self) -> Option<char>
pub const fn as_char(&self) -> Option<char>
Returns a char if the value is a char, otherwise None
.
sourcepub fn to_string(&self) -> Option<String>
pub fn to_string(&self) -> Option<String>
Returns a cloned String if the value is text, otherwise None
.
sourcepub fn into_string(self) -> Option<String>
pub fn into_string(self) -> Option<String>
Transforms the Value
to a String
if it’s text,
otherwise None
.
sourcepub fn as_bytes(&self) -> Option<&[u8]>
pub fn as_bytes(&self) -> Option<&[u8]>
Returns a bytes slice if the value is text or a byte slice, otherwise None
.
sourcepub fn to_bytes(&self) -> Option<Vec<u8>>
pub fn to_bytes(&self) -> Option<Vec<u8>>
Returns a cloned Vec<u8>
if the value is text or a byte slice, otherwise None
.
sourcepub const fn is_integer(&self) -> bool
pub const fn is_integer(&self) -> bool
true
if the Value
is a signed integer.
sourcepub const fn as_i64(&self) -> Option<i64>
pub const fn as_i64(&self) -> Option<i64>
Returns an i64
if the value is a 64-bit signed integer, otherwise None
.
sourcepub const fn as_i32(&self) -> Option<i32>
pub const fn as_i32(&self) -> Option<i32>
Returns an i32
if the value is a 32-bit signed integer, otherwise None
.
sourcepub fn as_integer(&self) -> Option<i64>
pub fn as_integer(&self) -> Option<i64>
Returns an i64
if the value is a signed integer, otherwise None
.
sourcepub const fn as_f64(&self) -> Option<f64>
pub const fn as_f64(&self) -> Option<f64>
Returns a f64
if the value is a double, otherwise None
.
sourcepub const fn as_f32(&self) -> Option<f32>
pub const fn as_f32(&self) -> Option<f32>
Returns a f32
if the value is a double, otherwise None
.
sourcepub const fn is_numeric(&self) -> bool
Available on crate feature bigdecimal
only.
pub const fn is_numeric(&self) -> bool
bigdecimal
only.true
if the Value
is a numeric value or can be converted to one.
sourcepub fn into_numeric(self) -> Option<BigDecimal>
Available on crate feature bigdecimal
only.
pub fn into_numeric(self) -> Option<BigDecimal>
bigdecimal
only.Returns a bigdecimal, if the value is a numeric, float or double value,
otherwise None
.
sourcepub const fn as_numeric(&self) -> Option<&BigDecimal>
Available on crate feature bigdecimal
only.
pub const fn as_numeric(&self) -> Option<&BigDecimal>
bigdecimal
only.Returns a reference to a bigdecimal, if the value is a numeric.
Otherwise None
.
sourcepub const fn as_bool(&self) -> Option<bool>
pub const fn as_bool(&self) -> Option<bool>
Returns a bool if the value is a boolean, otherwise None
.
sourcepub const fn is_uuid(&self) -> bool
Available on crate feature uuid
only.
pub const fn is_uuid(&self) -> bool
uuid
only.true
if the Value
is of UUID type.
sourcepub const fn as_uuid(&self) -> Option<Uuid>
Available on crate feature uuid
only.
pub const fn as_uuid(&self) -> Option<Uuid>
uuid
only.Returns an UUID if the value is of UUID type, otherwise None
.
sourcepub const fn is_datetime(&self) -> bool
Available on crate feature chrono
only.
pub const fn is_datetime(&self) -> bool
chrono
only.true
if the Value
is a DateTime.
sourcepub const fn as_datetime(&self) -> Option<DateTime<Utc>>
Available on crate feature chrono
only.
pub const fn as_datetime(&self) -> Option<DateTime<Utc>>
chrono
only.Returns a DateTime
if the value is a DateTime
, otherwise None
.
sourcepub const fn is_date(&self) -> bool
Available on crate feature chrono
only.
pub const fn is_date(&self) -> bool
chrono
only.true
if the Value
is a Date.
sourcepub const fn as_date(&self) -> Option<NaiveDate>
Available on crate feature chrono
only.
pub const fn as_date(&self) -> Option<NaiveDate>
chrono
only.Returns a NaiveDate
if the value is a Date
, otherwise None
.
sourcepub const fn is_time(&self) -> bool
Available on crate feature chrono
only.
pub const fn is_time(&self) -> bool
chrono
only.true
if the Value
is a Time
.
sourcepub const fn as_time(&self) -> Option<NaiveTime>
Available on crate feature chrono
only.
pub const fn as_time(&self) -> Option<NaiveTime>
chrono
only.Returns a NaiveTime
if the value is a Time
, otherwise None
.
sourcepub const fn is_json(&self) -> bool
Available on crate feature json
only.
pub const fn is_json(&self) -> bool
json
only.true
if the Value
is a JSON value.
sourcepub const fn as_json(&self) -> Option<&Value>
Available on crate feature json
only.
pub const fn as_json(&self) -> Option<&Value>
json
only.Returns a reference to a JSON Value if of Json type, otherwise None
.
sourcepub fn into_json(self) -> Option<Value>
Available on crate feature json
only.
pub fn into_json(self) -> Option<Value>
json
only.Transforms to a JSON Value if of Json type, otherwise None
.
Trait Implementations§
source§impl<'de> IntoDeserializer<'de, Error> for Value<'de>
Available on crate feature serde-support
only.
impl<'de> IntoDeserializer<'de, Error> for Value<'de>
serde-support
only.§type Deserializer = ValueDeserializer<'de>
type Deserializer = ValueDeserializer<'de>
source§fn into_deserializer(self) -> Self::Deserializer
fn into_deserializer(self) -> Self::Deserializer
source§impl<'a> PartialEq<Value<'a>> for Value<'a>
impl<'a> PartialEq<Value<'a>> for Value<'a>
source§impl<'a> ToSql for Value<'a>
impl<'a> ToSql for Value<'a>
source§fn to_sql(
&self,
ty: &PostgresType,
out: &mut BytesMut
) -> Result<IsNull, Box<dyn StdError + Send + Sync + 'static>>
fn to_sql( &self, ty: &PostgresType, out: &mut BytesMut ) -> Result<IsNull, Box<dyn StdError + Send + Sync + 'static>>
self
into the binary format of the specified
Postgres Type
, appending it to out
. Read moresource§fn accepts(_: &PostgresType) -> bool
fn accepts(_: &PostgresType) -> bool
Type
.source§fn to_sql_checked(
&self,
ty: &Type,
out: &mut BytesMut
) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn to_sql_checked( &self, ty: &Type, out: &mut BytesMut ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
source§fn encode_format(&self, _ty: &Type) -> Format
fn encode_format(&self, _ty: &Type) -> Format
impl<'a> StructuralPartialEq for Value<'a>
impl ValueIndex<ResultRow, Value<'static>> for &str
impl ValueIndex<ResultRow, Value<'static>> for usize
impl ValueIndex<ResultRowRef<'_>, Value<'static>> for &str
impl ValueIndex<ResultRowRef<'_>, Value<'static>> for usize
Auto Trait Implementations§
impl<'a> RefUnwindSafe for Value<'a>
impl<'a> Send for Value<'a>
impl<'a> Sync for Value<'a>
impl<'a> Unpin for Value<'a>
impl<'a> UnwindSafe for Value<'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> BorrowToSql for Twhere
T: ToSql,
impl<T> BorrowToSql for Twhere T: ToSql,
source§fn borrow_to_sql(&self) -> &dyn ToSql
fn borrow_to_sql(&self) -> &dyn ToSql
self
as a ToSql
trait object.source§impl<'a, T> Conjunctive<'a> for Twhere
T: Into<Expression<'a>>,
impl<'a, T> Conjunctive<'a> for Twhere T: Into<Expression<'a>>,
source§fn and<E>(self, other: E) -> ConditionTree<'a>where
E: Into<Expression<'a>>,
fn and<E>(self, other: E) -> ConditionTree<'a>where E: Into<Expression<'a>>,
source§fn or<E>(self, other: E) -> ConditionTree<'a>where
E: Into<Expression<'a>>,
fn or<E>(self, other: E) -> ConditionTree<'a>where E: Into<Expression<'a>>,
source§fn not(self) -> ConditionTree<'a>
fn not(self) -> ConditionTree<'a>
§impl<T> Conv for T
impl<T> Conv for T
§impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
§impl<T> FmtForward for T
impl<T> FmtForward for T
§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.§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.§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.§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.§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.§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.§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.§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.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where &'a Self: for<'a> IntoIterator,
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>
§impl<T, U, I> LiftInto<U, I> for Twhere
U: LiftFrom<T, I>,
impl<T, U, I> LiftInto<U, I> for Twhere U: LiftFrom<T, I>,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere Self: Sized,
§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 more§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 more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere Self: Borrow<B>, B: 'a + ?Sized, R: 'a,
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> Rwhere Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere Self: AsRef<U>, U: 'a + ?Sized, R: 'a,
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere Self: AsMut<U>, U: 'a + ?Sized, R: 'a,
self
, then passes self.as_mut()
into the pipe
function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<Source> Sculptor<HNil, HNil> for Source
impl<Source> Sculptor<HNil, HNil> for Source
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere Self: Deref<Target = T>, T: ?Sized,
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere Self: DerefMut<Target = T> + Deref, T: ?Sized,
Deref::Target
of a value. Read more§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.§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.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
.tap_ref_mut()
only in debug builds, and is erased in release
builds.