Enum butane::SqlVal

source ·
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

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, Global>)

§

Json(Value)

§

Timestamp(NaiveDateTime)

§

Custom(Box<SqlValCustom, Global>)

Implementations§

source§

impl SqlVal

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source

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

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<(), Error>

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

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

source§

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 Display for SqlVal

source§

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

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) -> SqlVal

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 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

source§

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 more
source§

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>>

An adaptor method used internally by Rust-Postgres. Read more
source§

fn encode_format(&self, _ty: &Type) -> Format

Specify the encode format
source§

impl ToSql for SqlVal

source§

fn to_sql(&self) -> Result<ToSqlOutput<'_>, Error>

Converts Rust value to SQLite value
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> BorrowToSql for Twhere T: ToSql,

source§

fn borrow_to_sql(&self) -> &dyn ToSql

Returns a reference to self as a ToSql trait object.
§

impl<T> Fake for T

§

fn fake<U>(&self) -> Uwhere Self: FakeBase<U>,

§

fn fake_with_rng<U, R>(&self, rng: &mut R) -> Uwhere R: Rng + ?Sized, Self: FakeBase<U>,

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same<T> for T

§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

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