Trait diesel::serialize::ToSql [−][src]
pub trait ToSql<A, DB: Backend>: Debug { fn to_sql<W: Write>(&self, out: &mut Output<W, DB>) -> Result; }
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
ToSql
implementation. - For MySQL, the expected bytes will depend on the return value of
type_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<'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<Datetime, Mysql> for MYSQL_TIME
[src]
impl ToSql<Datetime, Mysql> for MYSQL_TIME
impl ToSql<Timestamp, Mysql> for MYSQL_TIME
[src]
impl ToSql<Timestamp, Mysql> for MYSQL_TIME
impl ToSql<Time, Mysql> for MYSQL_TIME
[src]
impl ToSql<Time, Mysql> for MYSQL_TIME
impl ToSql<Date, Mysql> for MYSQL_TIME
[src]
impl ToSql<Date, Mysql> for MYSQL_TIME
impl ToSql<Datetime, Mysql> for NaiveDateTime
[src]
impl ToSql<Datetime, Mysql> for NaiveDateTime
impl ToSql<Timestamp, Mysql> for NaiveDateTime
[src]
impl ToSql<Timestamp, Mysql> for NaiveDateTime
impl ToSql<Time, Mysql> for NaiveTime
[src]
impl ToSql<Time, Mysql> for NaiveTime
impl ToSql<Date, Mysql> for NaiveDate
[src]
impl ToSql<Date, Mysql> for NaiveDate
impl ToSql<Tinyint, Mysql> for i8
[src]
impl ToSql<Tinyint, Mysql> for i8
impl ToSql<Unsigned<SmallInt>, Mysql> for u16
[src]
impl ToSql<Unsigned<SmallInt>, Mysql> for u16
impl ToSql<Unsigned<Integer>, Mysql> for u32
[src]
impl ToSql<Unsigned<Integer>, Mysql> for u32
impl ToSql<Unsigned<BigInt>, Mysql> for u64
[src]
impl ToSql<Unsigned<BigInt>, Mysql> for u64
impl ToSql<Bool, Mysql> for bool
[src]
impl ToSql<Bool, Mysql> for bool
impl<ST, T> ToSql<Array<ST>, Pg> for [T] where
Pg: HasSqlType<ST>,
T: ToSql<ST, Pg>,
[src]
impl<ST, T> ToSql<Array<ST>, Pg> for [T] where
Pg: HasSqlType<ST>,
T: ToSql<ST, Pg>,
impl<ST, T> ToSql<Nullable<Array<ST>>, Pg> for [T] where
[T]: ToSql<Array<ST>, Pg>,
[src]
impl<ST, T> ToSql<Nullable<Array<ST>>, Pg> for [T] where
[T]: ToSql<Array<ST>, Pg>,
impl<ST, T> ToSql<Array<ST>, Pg> for Vec<T> where
[T]: ToSql<Array<ST>, Pg>,
T: Debug,
[src]
impl<ST, T> ToSql<Array<ST>, Pg> for Vec<T> where
[T]: ToSql<Array<ST>, Pg>,
T: Debug,
impl<ST, T> ToSql<Nullable<Array<ST>>, Pg> for Vec<T> where
Vec<T>: ToSql<Array<ST>, Pg>,
[src]
impl<ST, T> ToSql<Nullable<Array<ST>>, Pg> for Vec<T> where
Vec<T>: ToSql<Array<ST>, Pg>,
impl ToSql<Timestamp, Pg> for NaiveDateTime
[src]
impl ToSql<Timestamp, Pg> for NaiveDateTime
impl ToSql<Timestamptz, Pg> for NaiveDateTime
[src]
impl ToSql<Timestamptz, Pg> for NaiveDateTime
impl<TZ: TimeZone> ToSql<Timestamptz, Pg> for DateTime<TZ>
[src]
impl<TZ: TimeZone> ToSql<Timestamptz, Pg> for DateTime<TZ>
impl ToSql<Time, Pg> for NaiveTime
[src]
impl ToSql<Time, Pg> for NaiveTime
impl ToSql<Date, Pg> for NaiveDate
[src]
impl ToSql<Date, Pg> for NaiveDate
impl ToSql<Timestamp, Pg> for SystemTime
[src]
impl ToSql<Timestamp, Pg> for SystemTime
impl ToSql<Oid, Pg> for u32
[src]
impl ToSql<Oid, Pg> for u32
impl ToSql<Bool, Pg> for bool
[src]
impl ToSql<Bool, Pg> for bool
impl<ST, T> ToSql<Range<ST>, Pg> for (Bound<T>, Bound<T>) where
T: ToSql<ST, Pg>,
[src]
impl<ST, T> ToSql<Range<ST>, Pg> for (Bound<T>, Bound<T>) where
T: ToSql<ST, Pg>,
impl<ST, T> ToSql<Nullable<Range<ST>>, Pg> for (Bound<T>, Bound<T>) where
(Bound<T>, Bound<T>): ToSql<Range<ST>, Pg>,
[src]
impl<ST, T> ToSql<Nullable<Range<ST>>, Pg> for (Bound<T>, Bound<T>) where
(Bound<T>, Bound<T>): ToSql<Range<ST>, Pg>,
impl ToSql<Date, Sqlite> for NaiveDate
[src]
impl ToSql<Date, Sqlite> for NaiveDate
impl ToSql<Time, Sqlite> for NaiveTime
[src]
impl ToSql<Time, Sqlite> for NaiveTime
impl ToSql<Timestamp, Sqlite> for NaiveDateTime
[src]
impl ToSql<Timestamp, Sqlite> for NaiveDateTime
impl ToSql<Date, Sqlite> for str
[src]
impl ToSql<Date, Sqlite> for str
impl ToSql<Date, Sqlite> for String
[src]
impl ToSql<Date, Sqlite> for String
impl ToSql<Time, Sqlite> for str
[src]
impl ToSql<Time, Sqlite> for str
impl ToSql<Time, Sqlite> for String
[src]
impl ToSql<Time, Sqlite> for String
impl ToSql<Timestamp, Sqlite> for str
[src]
impl ToSql<Timestamp, Sqlite> for str
impl ToSql<Timestamp, Sqlite> for String
[src]
impl ToSql<Timestamp, Sqlite> for String
impl ToSql<Bool, Sqlite> for bool
[src]
impl ToSql<Bool, Sqlite> for bool
impl<__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> ToSql<Nullable<Timestamptz>, __DB> for NaiveDateTime where
__DB: Backend,
Self: ToSql<Timestamptz, __DB>,
[src]
impl<__DB> ToSql<Nullable<Timestamptz>, __DB> for NaiveDateTime where
__DB: Backend,
Self: ToSql<Timestamptz, __DB>,
impl<__DB> ToSql<Nullable<Datetime>, __DB> for NaiveDateTime where
__DB: Backend,
Self: ToSql<Datetime, __DB>,
[src]
impl<__DB> ToSql<Nullable<Datetime>, __DB> for NaiveDateTime where
__DB: Backend,
Self: ToSql<Datetime, __DB>,
impl<Tz: TimeZone, __DB> ToSql<Nullable<Timestamptz>, __DB> for DateTime<Tz> where
__DB: Backend,
Self: ToSql<Timestamptz, __DB>,
[src]
impl<Tz: TimeZone, __DB> ToSql<Nullable<Timestamptz>, __DB> for DateTime<Tz> where
__DB: Backend,
Self: ToSql<Timestamptz, __DB>,
impl<DB: Backend> ToSql<Float, DB> for f32
[src]
impl<DB: Backend> ToSql<Float, DB> for f32
impl<DB: Backend> ToSql<Double, DB> for f64
[src]
impl<DB: Backend> ToSql<Double, DB> for f64
impl<DB: Backend> ToSql<SmallInt, DB> for i16
[src]
impl<DB: Backend> ToSql<SmallInt, DB> for i16
impl<DB: Backend> ToSql<Integer, DB> for i32
[src]
impl<DB: Backend> ToSql<Integer, DB> for i32
impl<DB: Backend> ToSql<BigInt, DB> for i64
[src]
impl<DB: Backend> ToSql<BigInt, DB> for i64
impl<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<Tinyint>, __DB> for i8 where
__DB: Backend,
Self: ToSql<Tinyint, __DB>,
[src]
impl<__DB> ToSql<Nullable<Tinyint>, __DB> for i8 where
__DB: Backend,
Self: ToSql<Tinyint, __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<Unsigned<SmallInt>>, __DB> for u16 where
__DB: Backend,
Self: ToSql<Unsigned<SmallInt>, __DB>,
[src]
impl<__DB> ToSql<Nullable<Unsigned<SmallInt>>, __DB> for u16 where
__DB: Backend,
Self: ToSql<Unsigned<SmallInt>, __DB>,
impl<__DB> ToSql<Nullable<Unsigned<Integer>>, __DB> for u32 where
__DB: Backend,
Self: ToSql<Unsigned<Integer>, __DB>,
[src]
impl<__DB> ToSql<Nullable<Unsigned<Integer>>, __DB> for u32 where
__DB: Backend,
Self: ToSql<Unsigned<Integer>, __DB>,
impl<__DB> ToSql<Nullable<Oid>, __DB> for u32 where
__DB: Backend,
Self: ToSql<Oid, __DB>,
[src]
impl<__DB> ToSql<Nullable<Oid>, __DB> for u32 where
__DB: Backend,
Self: ToSql<Oid, __DB>,
impl<__DB> ToSql<Nullable<Unsigned<BigInt>>, __DB> for u64 where
__DB: Backend,
Self: ToSql<Unsigned<BigInt>, __DB>,
[src]
impl<__DB> ToSql<Nullable<Unsigned<BigInt>>, __DB> for u64 where
__DB: Backend,
Self: ToSql<Unsigned<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 str
impl<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,
Implementors
impl<__DB> ToSql<Nullable<Timestamp>, __DB> for PgTimestamp where
__DB: Backend,
Self: ToSql<Timestamp, __DB>,impl<__DB> ToSql<Nullable<Timestamptz>, __DB> for PgTimestamp where
__DB: Backend,
Self: ToSql<Timestamptz, __DB>,impl<__DB> ToSql<Nullable<Date>, __DB> for PgDate where
__DB: Backend,
Self: ToSql<Date, __DB>,impl<__DB> ToSql<Nullable<Time>, __DB> for PgTime where
__DB: Backend,
Self: ToSql<Time, __DB>,impl<__DB> ToSql<Nullable<Interval>, __DB> for PgInterval where
__DB: Backend,
Self: ToSql<Interval, __DB>,impl ToSql<Timestamp, Pg> for PgTimestamp
impl ToSql<Timestamptz, Pg> for PgTimestamp
impl ToSql<Date, Pg> for PgDate
impl ToSql<Time, Pg> for PgTime
impl ToSql<Interval, Pg> for PgInterval
impl<__DB> ToSql<Nullable<Numeric>, __DB> for PgNumeric where
__DB: Backend,
Self: ToSql<Numeric, __DB>,impl ToSql<Numeric, Pg> for PgNumeric
impl<__DB> ToSql<Nullable<Money>, __DB> for PgMoney where
__DB: Backend,
Self: ToSql<Money, __DB>,impl ToSql<Money, Pg> for PgMoney