[−][src]Trait diesel::serialize::ToSql  
Serializes a single value to be sent to the database.
The output is sent as a bind parameter, and the data must be written in the expected format for the given backend.
When possible, implementations of this trait should prefer using an existing
implementation, rather than writing to out directly. (For example, if you
are implementing this for an enum, which is represented as an integer in the
database, you should use i32::to_sql(x, out) instead of writing to out
yourself.
Any types which implement this trait should also #[derive(AsExpression)].
Backend specific details
- For PostgreSQL, the bytes will be sent using the binary protocol, not text.
 - For SQLite, all implementations should be written in terms of an existing
ToSqlimplementation. - For MySQL, the expected bytes will depend on the return value of
type_metadatafor the given SQL type. SeeMysqlTypefor details. - For third party backends, consult that backend's documentation.
 
Required Methods
Implementations on Foreign Types
impl<'a, A, T: ?Sized, DB> ToSql<A, DB> for &'a T where
    DB: Backend,
    T: ToSql<A, DB>, [src] 
impl<'a, A, T: ?Sized, DB> ToSql<A, DB> for &'a T where
    DB: Backend,
    T: ToSql<A, DB>, impl ToSql<Date, Sqlite> for NaiveDate[src] 
impl ToSql<Date, Sqlite> for NaiveDateimpl ToSql<Time, Sqlite> for NaiveTime[src] 
impl ToSql<Time, Sqlite> for NaiveTimeimpl ToSql<Timestamp, Sqlite> for NaiveDateTime[src] 
impl ToSql<Timestamp, Sqlite> for NaiveDateTimeimpl ToSql<Date, Sqlite> for str[src] 
impl ToSql<Date, Sqlite> for strimpl ToSql<Date, Sqlite> for String[src] 
impl ToSql<Date, Sqlite> for Stringimpl ToSql<Time, Sqlite> for str[src] 
impl ToSql<Time, Sqlite> for strimpl ToSql<Time, Sqlite> for String[src] 
impl ToSql<Time, Sqlite> for Stringimpl ToSql<Timestamp, Sqlite> for str[src] 
impl ToSql<Timestamp, Sqlite> for strimpl ToSql<Timestamp, Sqlite> for String[src] 
impl ToSql<Timestamp, Sqlite> for Stringimpl ToSql<Bool, Sqlite> for bool[src] 
impl ToSql<Bool, Sqlite> for boolimpl<__DB> ToSql<Nullable<Timestamp>, __DB> for SystemTime where
    __DB: Backend,
    Self: ToSql<Timestamp, __DB>, [src] 
impl<__DB> ToSql<Nullable<Timestamp>, __DB> for SystemTime where
    __DB: Backend,
    Self: ToSql<Timestamp, __DB>, impl<__DB> ToSql<Nullable<Date>, __DB> for NaiveDate where
    __DB: Backend,
    Self: ToSql<Date, __DB>, [src] 
impl<__DB> ToSql<Nullable<Date>, __DB> for NaiveDate where
    __DB: Backend,
    Self: ToSql<Date, __DB>, impl<__DB> ToSql<Nullable<Time>, __DB> for NaiveTime where
    __DB: Backend,
    Self: ToSql<Time, __DB>, [src] 
impl<__DB> ToSql<Nullable<Time>, __DB> for NaiveTime where
    __DB: Backend,
    Self: ToSql<Time, __DB>, impl<__DB> ToSql<Nullable<Timestamp>, __DB> for NaiveDateTime where
    __DB: Backend,
    Self: ToSql<Timestamp, __DB>, [src] 
impl<__DB> ToSql<Nullable<Timestamp>, __DB> for NaiveDateTime where
    __DB: Backend,
    Self: ToSql<Timestamp, __DB>, impl<DB: Backend> ToSql<Float, DB> for f32[src] 
impl<DB: Backend> ToSql<Float, DB> for f32impl<DB: Backend> ToSql<Double, DB> for f64[src] 
impl<DB: Backend> ToSql<Double, DB> for f64impl<DB: Backend> ToSql<SmallInt, DB> for i16[src] 
impl<DB: Backend> ToSql<SmallInt, DB> for i16impl<DB: Backend> ToSql<Integer, DB> for i32[src] 
impl<DB: Backend> ToSql<Integer, DB> for i32impl<DB: Backend> ToSql<BigInt, DB> for i64[src] 
impl<DB: Backend> ToSql<BigInt, DB> for i64impl<T, ST, DB> ToSql<Nullable<ST>, DB> for Option<T> where
    T: ToSql<ST, DB>,
    DB: Backend,
    ST: NotNull, [src] 
impl<T, ST, DB> ToSql<Nullable<ST>, DB> for Option<T> where
    T: ToSql<ST, DB>,
    DB: Backend,
    ST: NotNull, impl<__DB> ToSql<Nullable<Bool>, __DB> for bool where
    __DB: Backend,
    Self: ToSql<Bool, __DB>, [src] 
impl<__DB> ToSql<Nullable<Bool>, __DB> for bool where
    __DB: Backend,
    Self: ToSql<Bool, __DB>, impl<__DB> ToSql<Nullable<SmallInt>, __DB> for i16 where
    __DB: Backend,
    Self: ToSql<SmallInt, __DB>, [src] 
impl<__DB> ToSql<Nullable<SmallInt>, __DB> for i16 where
    __DB: Backend,
    Self: ToSql<SmallInt, __DB>, impl<__DB> ToSql<Nullable<Integer>, __DB> for i32 where
    __DB: Backend,
    Self: ToSql<Integer, __DB>, [src] 
impl<__DB> ToSql<Nullable<Integer>, __DB> for i32 where
    __DB: Backend,
    Self: ToSql<Integer, __DB>, impl<__DB> ToSql<Nullable<BigInt>, __DB> for i64 where
    __DB: Backend,
    Self: ToSql<BigInt, __DB>, [src] 
impl<__DB> ToSql<Nullable<BigInt>, __DB> for i64 where
    __DB: Backend,
    Self: ToSql<BigInt, __DB>, impl<__DB> ToSql<Nullable<Float>, __DB> for f32 where
    __DB: Backend,
    Self: ToSql<Float, __DB>, [src] 
impl<__DB> ToSql<Nullable<Float>, __DB> for f32 where
    __DB: Backend,
    Self: ToSql<Float, __DB>, impl<__DB> ToSql<Nullable<Double>, __DB> for f64 where
    __DB: Backend,
    Self: ToSql<Double, __DB>, [src] 
impl<__DB> ToSql<Nullable<Double>, __DB> for f64 where
    __DB: Backend,
    Self: ToSql<Double, __DB>, impl<__DB> ToSql<Nullable<Text>, __DB> for String where
    __DB: Backend,
    Self: ToSql<Text, __DB>, [src] 
impl<__DB> ToSql<Nullable<Text>, __DB> for String where
    __DB: Backend,
    Self: ToSql<Text, __DB>, impl<__DB> ToSql<Nullable<Date>, __DB> for String where
    __DB: Backend,
    Self: ToSql<Date, __DB>, [src] 
impl<__DB> ToSql<Nullable<Date>, __DB> for String where
    __DB: Backend,
    Self: ToSql<Date, __DB>, impl<__DB> ToSql<Nullable<Time>, __DB> for String where
    __DB: Backend,
    Self: ToSql<Time, __DB>, [src] 
impl<__DB> ToSql<Nullable<Time>, __DB> for String where
    __DB: Backend,
    Self: ToSql<Time, __DB>, impl<__DB> ToSql<Nullable<Timestamp>, __DB> for String where
    __DB: Backend,
    Self: ToSql<Timestamp, __DB>, [src] 
impl<__DB> ToSql<Nullable<Timestamp>, __DB> for String where
    __DB: Backend,
    Self: ToSql<Timestamp, __DB>, impl<__DB> ToSql<Nullable<Text>, __DB> for str where
    __DB: Backend,
    Self: ToSql<Text, __DB>, [src] 
impl<__DB> ToSql<Nullable<Text>, __DB> for str where
    __DB: Backend,
    Self: ToSql<Text, __DB>, impl<__DB> ToSql<Nullable<Date>, __DB> for str where
    __DB: Backend,
    Self: ToSql<Date, __DB>, [src] 
impl<__DB> ToSql<Nullable<Date>, __DB> for str where
    __DB: Backend,
    Self: ToSql<Date, __DB>, impl<__DB> ToSql<Nullable<Time>, __DB> for str where
    __DB: Backend,
    Self: ToSql<Time, __DB>, [src] 
impl<__DB> ToSql<Nullable<Time>, __DB> for str where
    __DB: Backend,
    Self: ToSql<Time, __DB>, impl<__DB> ToSql<Nullable<Timestamp>, __DB> for str where
    __DB: Backend,
    Self: ToSql<Timestamp, __DB>, [src] 
impl<__DB> ToSql<Nullable<Timestamp>, __DB> for str where
    __DB: Backend,
    Self: ToSql<Timestamp, __DB>, impl<__DB> ToSql<Nullable<Binary>, __DB> for Vec<u8> where
    __DB: Backend,
    Self: ToSql<Binary, __DB>, [src] 
impl<__DB> ToSql<Nullable<Binary>, __DB> for Vec<u8> where
    __DB: Backend,
    Self: ToSql<Binary, __DB>, impl<__DB> ToSql<Nullable<Binary>, __DB> for [u8] where
    __DB: Backend,
    Self: ToSql<Binary, __DB>, [src] 
impl<__DB> ToSql<Nullable<Binary>, __DB> for [u8] where
    __DB: Backend,
    Self: ToSql<Binary, __DB>, impl<DB: Backend> ToSql<Text, DB> for str[src] 
impl<DB: Backend> ToSql<Text, DB> for strimpl<DB> ToSql<Text, DB> for String where
    DB: Backend,
    str: ToSql<Text, DB>, [src] 
impl<DB> ToSql<Text, DB> for String where
    DB: Backend,
    str: ToSql<Text, DB>, impl<DB> ToSql<Binary, DB> for Vec<u8> where
    DB: Backend,
    [u8]: ToSql<Binary, DB>, [src] 
impl<DB> ToSql<Binary, DB> for Vec<u8> where
    DB: Backend,
    [u8]: ToSql<Binary, DB>, impl<DB: Backend> ToSql<Binary, DB> for [u8][src] 
impl<DB: Backend> ToSql<Binary, DB> for [u8]impl<'a, T: ?Sized, ST, DB> ToSql<ST, DB> for Cow<'a, T> where
    T: 'a + ToOwned + ToSql<ST, DB>,
    DB: Backend,
    Self: Debug, [src] 
impl<'a, T: ?Sized, ST, DB> ToSql<ST, DB> for Cow<'a, T> where
    T: 'a + ToOwned + ToSql<ST, DB>,
    DB: Backend,
    Self: Debug,