FromSql

Trait FromSql 

Source
pub trait FromSql: Sized {
    // Required method
    fn from_sql(value: &SqlValue) -> Result<Self, TypeError>;

    // Provided method
    fn from_sql_nullable(value: &SqlValue) -> Result<Option<Self>, TypeError> { ... }
}
Expand description

Trait for types that can be converted from SQL values.

This trait is implemented for common Rust types to enable type-safe extraction of values from query results.

Required Methods§

Source

fn from_sql(value: &SqlValue) -> Result<Self, TypeError>

Convert from a SQL value to this type.

Provided Methods§

Source

fn from_sql_nullable(value: &SqlValue) -> Result<Option<Self>, TypeError>

Convert from an optional SQL value.

Returns None if the value is NULL.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl FromSql for bool

Source§

impl FromSql for f32

Source§

impl FromSql for f64

Source§

impl FromSql for i16

Source§

impl FromSql for i32

Source§

impl FromSql for i64

Source§

impl FromSql for u8

Source§

impl FromSql for String

Source§

impl FromSql for Vec<u8>

Source§

impl FromSql for DateTime<FixedOffset>

Available on crate feature chrono only.
Source§

impl FromSql for DateTime<Utc>

Available on crate feature chrono only.
Source§

impl FromSql for NaiveDate

Available on crate feature chrono only.
Source§

impl FromSql for NaiveDateTime

Available on crate feature chrono only.
Source§

impl FromSql for NaiveTime

Available on crate feature chrono only.
Source§

impl FromSql for Decimal

Available on crate feature decimal only.
Source§

impl FromSql for Uuid

Available on crate feature uuid only.
Source§

impl<T: FromSql> FromSql for Option<T>

Implementors§