ToSql

Trait ToSql 

Source
pub trait ToSql {
    // Required methods
    fn to_sql(&self) -> Result<SqlValue, TypeError>;
    fn sql_type(&self) -> &'static str;
}
Expand description

Trait for types that can be converted to SQL values.

This trait is implemented for common Rust types to enable type-safe parameter binding in queries.

Required Methods§

Source

fn to_sql(&self) -> Result<SqlValue, TypeError>

Convert this value to a SQL value.

Source

fn sql_type(&self) -> &'static str

Get the SQL type name for this value.

Implementations on Foreign Types§

Source§

impl ToSql for bool

Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for f32

Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for f64

Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for i16

Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for i32

Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for i64

Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for str

Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for u8

Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for String

Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for Vec<u8>

Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for DateTime<FixedOffset>

Available on crate feature chrono only.
Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for DateTime<Utc>

Available on crate feature chrono only.
Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for NaiveDate

Available on crate feature chrono only.
Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for NaiveDateTime

Available on crate feature chrono only.
Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for NaiveTime

Available on crate feature chrono only.
Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for Decimal

Available on crate feature decimal only.
Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for Uuid

Available on crate feature uuid only.
Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for [u8]

Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl<T> ToSql for Option<T>
where T: ToSql,

Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl<T> ToSql for &T
where T: ToSql + ?Sized,

Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Implementors§