Skip to main content

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.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

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

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 Value

Available on crate feature json only.
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 [u8]

Source§

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

Source§

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

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<T: ToSql + ?Sized> ToSql for &T

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Implementors§

Source§

impl ToSql for Money

Available on crate feature decimal only.
Source§

impl ToSql for SmallDateTime

Available on crate feature chrono only.
Source§

impl ToSql for SmallMoney

Available on crate feature decimal only.