Trait diesel::deserialize::FromSql
[−]
[src]
pub trait FromSql<A, DB: Backend>: Sized { fn from_sql(bytes: Option<&DB::RawValue>) -> Result<Self>; }
Deserialize a single field of a given SQL type.
When possible, implementations of this trait should prefer to use an
existing implementation, rather than reading from bytes
. (For example, if
you are implementing this for an enum which is represented as an integer in
the database, prefer i32::from_sql(bytes)
over reading from bytes
directly)
Types which implement this trait should also have #[derive(FromSqlRow)]
Backend specific details
- For PostgreSQL, the bytes will be sent using the binary protocol, not text.
- For SQLite, the actual type of
DB::RawValue
is private API. All implementations of this trait must be written in terms of an existing primitive. - For MySQL, the value of
bytes
will depend on the return value oftype_metadata
for the given SQL type. SeeMysqlType
for details. - For third party backends, consult that backend's documentation.
Required Methods
Implementations on Foreign Types
impl FromSql<Datetime, Mysql> for MYSQL_TIME
[src]
impl FromSql<Timestamp, Mysql> for MYSQL_TIME
[src]
impl FromSql<Time, Mysql> for MYSQL_TIME
[src]
impl FromSql<Date, Mysql> for MYSQL_TIME
[src]
impl FromSql<Datetime, Mysql> for NaiveDateTime
[src]
impl FromSql<Timestamp, Mysql> for NaiveDateTime
[src]
impl FromSql<Time, Mysql> for NaiveTime
[src]
impl FromSql<Date, Mysql> for NaiveDate
[src]
impl FromSql<Numeric, Mysql> for BigDecimal
[src]
impl FromSql<Tinyint, Mysql> for i8
[src]
impl FromSql<Bool, Mysql> for bool
[src]
impl<T, ST> FromSql<Array<ST>, Pg> for Vec<T> where
T: FromSql<ST, Pg>,
[src]
T: FromSql<ST, Pg>,
impl<T, ST> FromSql<Range<ST>, Pg> for (Bound<T>, Bound<T>) where
T: FromSql<ST, Pg>,
[src]
T: FromSql<ST, Pg>,
impl FromSql<Timestamp, Pg> for SystemTime
[src]
impl FromSql<Timestamp, Pg> for NaiveDateTime
[src]
impl FromSql<Timestamptz, Pg> for NaiveDateTime
[src]
impl FromSql<Timestamptz, Pg> for DateTime<Utc>
[src]
impl FromSql<Time, Pg> for NaiveTime
[src]
impl FromSql<Date, Pg> for NaiveDate
[src]
impl FromSql<Timestamp, Pg> for Timespec
[src]
impl FromSql<MacAddr, Pg> for [u8; 6]
[src]
impl FromSql<Inet, Pg> for IpNetwork
[src]
impl FromSql<Cidr, Pg> for IpNetwork
[src]
impl FromSql<Oid, Pg> for u32
[src]
impl FromSql<Numeric, Pg> for BigDecimal
[src]
impl FromSql<Bool, Pg> for bool
[src]
impl FromSql<Uuid, Pg> for Uuid
[src]
impl FromSql<Json, Pg> for Value
[src]
impl FromSql<Jsonb, Pg> for Value
[src]
impl FromSql<Date, Sqlite> for NaiveDate
[src]
impl FromSql<Time, Sqlite> for NaiveTime
[src]
impl FromSql<Timestamp, Sqlite> for NaiveDateTime
[src]
impl FromSql<Date, Sqlite> for *const str
[src]
The returned pointer is only valid for the lifetime to the argument of
from_sql
. This impl is intended for uses where you want to write a new
impl in terms of String
, but don't want to allocate. We have to return a
raw pointer instead of a reference with a lifetime due to the structure of
FromSql
impl FromSql<Time, Sqlite> for *const str
[src]
The returned pointer is only valid for the lifetime to the argument of
from_sql
. This impl is intended for uses where you want to write a new
impl in terms of String
, but don't want to allocate. We have to return a
raw pointer instead of a reference with a lifetime due to the structure of
FromSql
impl FromSql<Timestamp, Sqlite> for *const str
[src]
The returned pointer is only valid for the lifetime to the argument of
from_sql
. This impl is intended for uses where you want to write a new
impl in terms of String
, but don't want to allocate. We have to return a
raw pointer instead of a reference with a lifetime due to the structure of
FromSql
impl FromSql<VarChar, Sqlite> for *const str
[src]
The returned pointer is only valid for the lifetime to the argument of
from_sql
. This impl is intended for uses where you want to write a new
impl in terms of String
, but don't want to allocate. We have to return a
raw pointer instead of a reference with a lifetime due to the structure of
FromSql
impl FromSql<Binary, Sqlite> for *const [u8]
[src]
The returned pointer is only valid for the lifetime to the argument of
from_sql
. This impl is intended for uses where you want to write a new
impl in terms of Vec<u8>
, but don't want to allocate. We have to return a
raw pointer instead of a reference with a lifetime due to the structure of
FromSql
impl FromSql<SmallInt, Sqlite> for i16
[src]
impl FromSql<Integer, Sqlite> for i32
[src]
impl FromSql<Bool, Sqlite> for bool
[src]
impl FromSql<BigInt, Sqlite> for i64
[src]
impl FromSql<Float, Sqlite> for f32
[src]
impl FromSql<Double, Sqlite> for f64
[src]
impl<DB: Backend<RawValue = [u8]>> FromSql<Float, DB> for f32
[src]
impl<DB: Backend<RawValue = [u8]>> FromSql<Double, DB> for f64
[src]
impl<DB: Backend<RawValue = [u8]>> FromSql<SmallInt, DB> for i16
[src]
impl<DB: Backend<RawValue = [u8]>> FromSql<Integer, DB> for i32
[src]
impl<DB: Backend<RawValue = [u8]>> FromSql<BigInt, DB> for i64
[src]
impl<T, ST, DB> FromSql<Nullable<ST>, DB> for Option<T> where
T: FromSql<ST, DB>,
DB: Backend,
ST: NotNull,
[src]
T: FromSql<ST, DB>,
DB: Backend,
ST: NotNull,
impl<ST, DB> FromSql<ST, DB> for String where
DB: Backend,
*const str: FromSql<ST, DB>,
[src]
DB: Backend,
*const str: FromSql<ST, DB>,
impl<DB: Backend<RawValue = [u8]>> FromSql<Text, DB> for *const str
[src]
The returned pointer is only valid for the lifetime to the argument of
from_sql
. This impl is intended for uses where you want to write a new
impl in terms of String
, but don't want to allocate. We have to return a
raw pointer instead of a reference with a lifetime due to the structure of
FromSql
impl<ST, DB> FromSql<ST, DB> for Vec<u8> where
DB: Backend,
*const [u8]: FromSql<ST, DB>,
[src]
DB: Backend,
*const [u8]: FromSql<ST, DB>,
impl<DB: Backend<RawValue = [u8]>> FromSql<Binary, DB> for *const [u8]
[src]
The returned pointer is only valid for the lifetime to the argument of
from_sql
. This impl is intended for uses where you want to write a new
impl in terms of Vec<u8>
, but don't want to allocate. We have to return a
raw pointer instead of a reference with a lifetime due to the structure of
FromSql
impl<'a, T: ?Sized, ST, DB> FromSql<ST, DB> for Cow<'a, T> where
T: 'a + ToOwned,
DB: Backend,
T::Owned: FromSql<ST, DB>,
[src]
T: 'a + ToOwned,
DB: Backend,
T::Owned: FromSql<ST, DB>,