pub enum SqlVal {
Null,
Bool(bool),
Int(i32),
BigInt(i64),
Real(f64),
Text(String),
Blob(Vec<u8, Global>),
Json(Value),
Timestamp(NaiveDateTime),
Custom(Box<SqlValCustom, Global>),
}
Expand description
Variants§
Null
Bool(bool)
Int(i32)
BigInt(i64)
Real(f64)
Text(String)
Blob(Vec<u8, Global>)
Json(Value)
Timestamp(NaiveDateTime)
Custom(Box<SqlValCustom, Global>)
Implementations§
source§impl SqlVal
impl SqlVal
pub fn as_ref(&self) -> SqlValRef<'_>
pub fn bool(&self) -> Result<bool, Error>
pub fn integer(&self) -> Result<i32, Error>
pub fn bigint(&self) -> Result<i64, Error>
pub fn real(&self) -> Result<f64, Error>
pub fn text(&self) -> Result<&str, Error>
pub fn owned_text(self) -> Result<String, Error>
pub fn blob(&self) -> Result<&[u8], Error>
pub fn owned_blob(self) -> Result<Vec<u8, Global>, Error>
sourcepub fn is_compatible(&self, t: &SqlType, null_allowed: bool) -> bool
pub fn is_compatible(&self, t: &SqlType, null_allowed: bool) -> bool
Tests if this sqlval is compatible with the given
SqlType
. There are no implicit type conversions (i.e. if
this is a SqlVal::Bool
, it is only compatible with
SqlType::Bool
, not with SqlType::Int
, even though an int
contains enough information to encode a bool.
pub fn sqltype(&self) -> Option<SqlType>
Trait Implementations§
source§impl<'de> Deserialize<'de> for SqlVal
impl<'de> Deserialize<'de> for SqlVal
source§fn deserialize<__D>(
__deserializer: __D
) -> Result<SqlVal, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>( __deserializer: __D ) -> Result<SqlVal, <__D as Deserializer<'de>>::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl PartialEq<SqlVal> for SqlVal
impl PartialEq<SqlVal> for SqlVal
source§impl Serialize for SqlVal
impl Serialize for SqlVal
source§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>( &self, __serializer: __S ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where __S: Serializer,
Serialize this value into the given Serde serializer. Read more
source§impl ToSql for SqlVal
impl ToSql for SqlVal
source§fn to_sql(
&self,
ty: &Type,
out: &mut BytesMut
) -> Result<IsNull, Box<dyn Error + Sync + Send + 'static, Global>>
fn to_sql( &self, ty: &Type, out: &mut BytesMut ) -> Result<IsNull, Box<dyn Error + Sync + Send + 'static, Global>>
Converts the value of
self
into the binary format of the specified
Postgres Type
, appending it to out
. Read moresource§fn accepts(ty: &Type) -> bool
fn accepts(ty: &Type) -> bool
Determines if a value of this type can be converted to the specified
Postgres
Type
.source§fn to_sql_checked(
&self,
ty: &Type,
out: &mut BytesMut
) -> Result<IsNull, Box<dyn Error + Sync + Send + 'static, Global>>
fn to_sql_checked( &self, ty: &Type, out: &mut BytesMut ) -> Result<IsNull, Box<dyn Error + Sync + Send + 'static, Global>>
An adaptor method used internally by Rust-Postgres. Read more
source§fn encode_format(&self, _ty: &Type) -> Format
fn encode_format(&self, _ty: &Type) -> Format
Specify the encode format
impl StructuralPartialEq for SqlVal
Auto Trait Implementations§
impl RefUnwindSafe for SqlVal
impl Send for SqlVal
impl Sync for SqlVal
impl Unpin for SqlVal
impl UnwindSafe for SqlVal
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
Mutably borrows from an owned value. Read more
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
Returns a reference to
self
as a ToSql
trait object.