pub enum SqlVal {
    Null,
    Bool(bool),
    Int(i32),
    BigInt(i64),
    Real(f64),
    Text(String),
    Blob(Vec<u8>),
    Custom(Box<SqlValCustom>),
}
Expand description

A database value.

For conversion between SqlVal and other types, see FromSql and ToSql.

Variants§

§

Null

§

Bool(bool)

§

Int(i32)

§

BigInt(i64)

§

Real(f64)

§

Text(String)

§

Blob(Vec<u8>)

§

Custom(Box<SqlValCustom>)

Implementations§

source§

impl SqlVal

source

pub fn as_ref(&self) -> SqlValRef<'_>

source

pub fn bool(&self) -> Result<bool>

source

pub fn integer(&self) -> Result<i32>

source

pub fn bigint(&self) -> Result<i64>

source

pub fn real(&self) -> Result<f64>

source

pub fn text(&self) -> Result<&str>

source

pub fn owned_text(self) -> Result<String>

source

pub fn blob(&self) -> Result<&[u8]>

source

pub fn owned_blob(self) -> Result<Vec<u8>>

source

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.

source

pub fn sqltype(&self) -> Option<SqlType>

Trait Implementations§

source§

impl Clone for SqlVal

source§

fn clone(&self) -> SqlVal

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for SqlVal

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for SqlVal

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for SqlVal

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> From<&'a SqlVal> for SqlValRef<'a>

source§

fn from(val: &'a SqlVal) -> SqlValRef<'a>

Converts to this type from the input type.
source§

impl From<SqlValRef<'_>> for SqlVal

source§

fn from(valref: SqlValRef<'_>) -> SqlVal

Converts to this type from the input type.
source§

impl<T> From<T> for SqlValwhere T: ToSql,

source§

fn from(val: T) -> Self

Converts to this type from the input type.
source§

impl PartialEq<SqlVal> for SqlVal

source§

fn eq(&self, other: &SqlVal) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for SqlVal

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl StructuralPartialEq for SqlVal

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,