pub struct Value<'a> {
pub typed: ValueType<'a>,
pub native_column_type: Option<NativeColumnType<'a>>,
}
Fields§
§typed: ValueType<'a>
§native_column_type: Option<NativeColumnType<'a>>
Implementations§
source§impl<'a> Value<'a>
impl<'a> Value<'a>
sourcepub fn native_column_type_name(&'a self) -> Option<&'a str>
pub fn native_column_type_name(&'a self) -> Option<&'a str>
Returns the native column type of the value, if any, in the form of an UPCASE string. ex: “VARCHAR, BYTEA, DATE, TIMEZ”
sourcepub fn with_native_column_type<T: Into<NativeColumnType<'a>>>(
self,
column_type: Option<T>
) -> Self
pub fn with_native_column_type<T: Into<NativeColumnType<'a>>>( self, column_type: Option<T> ) -> Self
Changes the value to include information about the native column type
sourcepub fn numeric(value: BigDecimal) -> Self
pub fn numeric(value: BigDecimal) -> Self
Creates a new decimal value.
sourcepub fn enum_variant<T>(value: T) -> Selfwhere
T: Into<EnumVariant<'a>>,
pub fn enum_variant<T>(value: T) -> Selfwhere T: Into<EnumVariant<'a>>,
Creates a new enum value.
sourcepub fn enum_variant_with_name<T, U>(value: T, name: U) -> Selfwhere
T: Into<EnumVariant<'a>>,
U: Into<EnumName<'a>>,
pub fn enum_variant_with_name<T, U>(value: T, name: U) -> Selfwhere T: Into<EnumVariant<'a>>, U: Into<EnumName<'a>>,
Creates a new enum value with the name of the enum attached.
sourcepub fn enum_array<T>(value: T) -> Selfwhere
T: IntoIterator<Item = EnumVariant<'a>>,
pub fn enum_array<T>(value: T) -> Selfwhere T: IntoIterator<Item = EnumVariant<'a>>,
Creates a new enum array value
sourcepub fn enum_array_with_name<T, U>(value: T, name: U) -> Selfwhere
T: IntoIterator<Item = EnumVariant<'a>>,
U: Into<EnumName<'a>>,
pub fn enum_array_with_name<T, U>(value: T, name: U) -> Selfwhere T: IntoIterator<Item = EnumVariant<'a>>, U: Into<EnumName<'a>>,
Creates a new enum array value with the name of the enum attached.
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 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 fn is_integer(&self) -> bool
pub fn is_integer(&self) -> bool
true
if the Value
is a signed integer.
sourcepub fn as_i64(&self) -> Option<i64>
pub fn as_i64(&self) -> Option<i64>
Returns an i64
if the value is a 64-bit signed integer, otherwise None
.
sourcepub fn as_i32(&self) -> Option<i32>
pub 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 fn is_numeric(&self) -> bool
pub fn is_numeric(&self) -> bool
true
if the Value
is a numeric value or can be converted to one.
sourcepub fn into_numeric(self) -> Option<BigDecimal>
pub fn into_numeric(self) -> Option<BigDecimal>
Returns a bigdecimal, if the value is a numeric, float or double value,
otherwise None
.
sourcepub fn as_numeric(&self) -> Option<&BigDecimal>
pub fn as_numeric(&self) -> Option<&BigDecimal>
Returns a reference to a bigdecimal, if the value is a numeric.
Otherwise None
.
sourcepub fn as_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
Returns a bool if the value is a boolean, otherwise None
.
sourcepub fn as_uuid(&self) -> Option<Uuid>
pub fn as_uuid(&self) -> Option<Uuid>
Returns an UUID if the value is of UUID type, otherwise None
.
sourcepub fn is_datetime(&self) -> bool
pub fn is_datetime(&self) -> bool
true
if the Value
is a DateTime.
sourcepub fn as_datetime(&self) -> Option<DateTime<Utc>>
pub fn as_datetime(&self) -> Option<DateTime<Utc>>
Returns a DateTime
if the value is a DateTime
, otherwise None
.
sourcepub fn as_date(&self) -> Option<NaiveDate>
pub fn as_date(&self) -> Option<NaiveDate>
Returns a NaiveDate
if the value is a Date
, otherwise None
.
sourcepub fn as_time(&self) -> Option<NaiveTime>
pub fn as_time(&self) -> Option<NaiveTime>
Returns a NaiveTime
if the value is a Time
, otherwise None
.
sourcepub fn as_json(&self) -> Option<&Value>
pub fn as_json(&self) -> Option<&Value>
Returns a reference to a JSON Value if of Json type, otherwise None
.
sourcepub fn into_json(self) -> Option<Value>
pub fn into_json(self) -> Option<Value>
Transforms to a JSON Value if of Json type, otherwise None
.
sourcepub fn into_vec<T>(self) -> Option<Vec<T>>where
T: TryFrom<Value<'a>>,
pub fn into_vec<T>(self) -> Option<Vec<T>>where T: TryFrom<Value<'a>>,
Returns a Vec<T>
if the value is an array of T
, otherwise None
.
sourcepub fn to_vec<T>(&self) -> Option<Vec<T>>where
T: TryFrom<Value<'a>>,
pub fn to_vec<T>(&self) -> Option<Vec<T>>where T: TryFrom<Value<'a>>,
Returns a cloned VecNone
.
pub fn null_int32() -> Self
pub fn null_int64() -> Self
pub fn null_float() -> Self
pub fn null_double() -> Self
pub fn null_text() -> Self
pub fn null_enum() -> Self
pub fn null_enum_array() -> Self
pub fn null_bytes() -> Self
pub fn null_boolean() -> Self
pub fn null_character() -> Self
pub fn null_array() -> Self
pub fn null_numeric() -> Self
pub fn null_json() -> Self
pub fn null_xml() -> Self
pub fn null_uuid() -> Self
pub fn null_datetime() -> Self
pub fn null_date() -> Self
pub fn null_time() -> Self
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<'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> PartialEq for Value<'a>
impl<'a> PartialEq for Value<'a>
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<'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 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> 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>
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> 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) -> 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,
source§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,
source§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.source§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.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)) -> 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 moresource§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 moresource§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 moresource§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 moresource§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 moresource§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 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)) -> 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.source§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.source§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.source§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.