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) -> Self
pub fn enum_variant<T>(value: T) -> Self
Creates a new enum 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<'a> From<BigDecimal> for Value<'a>
impl<'a> From<BigDecimal> for Value<'a>
Source§fn from(that: BigDecimal) -> Self
fn from(that: BigDecimal) -> Self
Source§impl<'a> From<Option<BigDecimal>> for Value<'a>
impl<'a> From<Option<BigDecimal>> for Value<'a>
Source§fn from(that: Option<BigDecimal>) -> Self
fn from(that: Option<BigDecimal>) -> Self
Source§impl<'de> IntoDeserializer<'de> for Value<'de>
Available on crate feature serde-support
only.
impl<'de> IntoDeserializer<'de> for Value<'de>
serde-support
only.Source§type Deserializer = ValueDeserializer<'de>
type Deserializer = ValueDeserializer<'de>
Source§fn into_deserializer(self) -> Self::Deserializer
fn into_deserializer(self) -> Self::Deserializer
Source§impl<'a> IntoSql<'a> for &'a Value<'a>
impl<'a> IntoSql<'a> for &'a Value<'a>
Source§fn into_sql(self) -> ColumnData<'a>
fn into_sql(self) -> ColumnData<'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
Source§impl<'a> ToSql for Value<'a>
impl<'a> ToSql for Value<'a>
Source§fn to_sql(&self) -> Result<ToSqlOutput<'_>, RusqlError>
fn to_sql(&self) -> Result<ToSqlOutput<'_>, RusqlError>
Source§impl TryFrom<ColumnData<'static>> for Value<'static>
impl TryFrom<ColumnData<'static>> for Value<'static>
Source§impl<'a> TryFrom<Value<'a>> for BigDecimal
impl<'a> TryFrom<Value<'a>> for BigDecimal
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> Freeze for Value<'a>
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Source§impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§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 moreSource§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 moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moreSource§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.Source§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.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.