pub trait Encode<'q, DB> where
DB: Database, {
fn encode_by_ref(
&self,
buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer
) -> IsNull;
fn encode(
self,
buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer
) -> IsNull { ... }
fn produces(&self) -> Option<<DB as Database>::TypeInfo> { ... }
fn size_hint(&self) -> usize { ... }
}
Expand description
Encode a single value to be sent to the database.
Required Methods
fn encode_by_ref(
&self,
buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer
) -> IsNull
fn encode_by_ref(
&self,
buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer
) -> IsNull
Writes the value of self
into buf
without moving self
.
Where possible, make use of encode
instead as it can take advantage of re-using
memory.
Provided Methods
fn encode(self, buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer) -> IsNull
fn encode(self, buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer) -> IsNull
Writes the value of self
into buf
in the expected format for the database.
Implementations on Foreign Types
sourceimpl<'_, '_> Encode<'_, Mssql> for Cow<'_, str>
impl<'_, '_> Encode<'_, Mssql> for Cow<'_, str>
fn produces(&self) -> Option<MssqlTypeInfo>
fn encode_by_ref(&self, buf: &mut Vec<u8, Global>) -> IsNull
sourceimpl<'_> Encode<'_, Postgres> for Duration
impl<'_> Encode<'_, Postgres> for Duration
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
sourceimpl<'q> Encode<'q, Sqlite> for Vec<u8, Global>
impl<'q> Encode<'q, Sqlite> for Vec<u8, Global>
fn encode(self, args: &mut Vec<SqliteArgumentValue<'q>, Global>) -> IsNull
fn encode_by_ref(
&self,
args: &mut Vec<SqliteArgumentValue<'q>, Global>
) -> IsNull
sourceimpl<'_, '_> Encode<'_, Mssql> for &'_ str
impl<'_, '_> Encode<'_, Mssql> for &'_ str
fn produces(&self) -> Option<MssqlTypeInfo>
fn encode_by_ref(&self, buf: &mut Vec<u8, Global>) -> IsNull
sourceimpl<'_> Encode<'_, Postgres> for Duration
impl<'_> Encode<'_, Postgres> for Duration
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
sourceimpl<'q> Encode<'q, Any> for f64 where
f64: AnyEncode<'q>,
impl<'q> Encode<'q, Any> for f64 where
f64: AnyEncode<'q>,
fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull
sourceimpl<'_> Encode<'_, Postgres> for String
impl<'_> Encode<'_, Postgres> for String
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
sourceimpl<'q> Encode<'q, Sqlite> for &'q [u8]
impl<'q> Encode<'q, Sqlite> for &'q [u8]
fn encode_by_ref(
&self,
args: &mut Vec<SqliteArgumentValue<'q>, Global>
) -> IsNull
sourceimpl<'_> Encode<'_, Postgres> for i64
impl<'_> Encode<'_, Postgres> for i64
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
sourceimpl<'_> Encode<'_, Postgres> for i8
impl<'_> Encode<'_, Postgres> for i8
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
sourceimpl<'q, T> Encode<'q, Sqlite> for Option<T> where
T: 'q + Encode<'q, Sqlite> + Type<Sqlite>,
impl<'q, T> Encode<'q, Sqlite> for Option<T> where
T: 'q + Encode<'q, Sqlite> + Type<Sqlite>,
fn produces(&self) -> Option<<Sqlite as Database>::TypeInfo>
fn encode(
self,
buf: &mut <Sqlite as HasArguments<'q>>::ArgumentBuffer
) -> IsNull
fn encode_by_ref(
&self,
buf: &mut <Sqlite as HasArguments<'q>>::ArgumentBuffer
) -> IsNull
fn size_hint(&self) -> usize
sourceimpl<'q> Encode<'q, Sqlite> for i8
impl<'q> Encode<'q, Sqlite> for i8
fn encode_by_ref(
&self,
args: &mut Vec<SqliteArgumentValue<'q>, Global>
) -> IsNull
sourceimpl<'q> Encode<'q, Sqlite> for f32
impl<'q> Encode<'q, Sqlite> for f32
fn encode_by_ref(
&self,
args: &mut Vec<SqliteArgumentValue<'q>, Global>
) -> IsNull
sourceimpl<'_> Encode<'_, Postgres> for f64
impl<'_> Encode<'_, Postgres> for f64
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
sourceimpl<'_> Encode<'_, Postgres> for bool
impl<'_> Encode<'_, Postgres> for bool
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
sourceimpl<'q> Encode<'q, Any> for f32 where
f32: AnyEncode<'q>,
impl<'q> Encode<'q, Any> for f32 where
f32: AnyEncode<'q>,
fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull
sourceimpl<'q> Encode<'q, Sqlite> for i16
impl<'q> Encode<'q, Sqlite> for i16
fn encode_by_ref(
&self,
args: &mut Vec<SqliteArgumentValue<'q>, Global>
) -> IsNull
sourceimpl<'q> Encode<'q, Sqlite> for Cow<'q, str>
impl<'q> Encode<'q, Sqlite> for Cow<'q, str>
fn encode(self, args: &mut Vec<SqliteArgumentValue<'q>, Global>) -> IsNull
fn encode_by_ref(
&self,
args: &mut Vec<SqliteArgumentValue<'q>, Global>
) -> IsNull
sourceimpl<'q> Encode<'q, Sqlite> for u8
impl<'q> Encode<'q, Sqlite> for u8
fn encode_by_ref(
&self,
args: &mut Vec<SqliteArgumentValue<'q>, Global>
) -> IsNull
sourceimpl<'q> Encode<'q, Any> for i16 where
i16: AnyEncode<'q>,
impl<'q> Encode<'q, Any> for i16 where
i16: AnyEncode<'q>,
fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull
sourceimpl<'q> Encode<'q, Sqlite> for String
impl<'q> Encode<'q, Sqlite> for String
fn encode(self, args: &mut Vec<SqliteArgumentValue<'q>, Global>) -> IsNull
fn encode_by_ref(
&self,
args: &mut Vec<SqliteArgumentValue<'q>, Global>
) -> IsNull
sourceimpl<'_> Encode<'_, Postgres> for Duration
impl<'_> Encode<'_, Postgres> for Duration
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
sourceimpl<'q> Encode<'q, Any> for &'q str where
&'q str: AnyEncode<'q>,
impl<'q> Encode<'q, Any> for &'q str where
&'q str: AnyEncode<'q>,
fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull
sourceimpl<'q, T> Encode<'q, MySql> for Option<T> where
T: 'q + Encode<'q, MySql> + Type<MySql>,
impl<'q, T> Encode<'q, MySql> for Option<T> where
T: 'q + Encode<'q, MySql> + Type<MySql>,
fn produces(&self) -> Option<<MySql as Database>::TypeInfo>
fn encode(self, buf: &mut <MySql as HasArguments<'q>>::ArgumentBuffer) -> IsNull
fn encode_by_ref(
&self,
buf: &mut <MySql as HasArguments<'q>>::ArgumentBuffer
) -> IsNull
fn size_hint(&self) -> usize
sourceimpl<'_, '_> Encode<'_, Postgres> for Cow<'_, str>
impl<'_, '_> Encode<'_, Postgres> for Cow<'_, str>
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
sourceimpl<'q> Encode<'q, Sqlite> for f64
impl<'q> Encode<'q, Sqlite> for f64
fn encode_by_ref(
&self,
args: &mut Vec<SqliteArgumentValue<'q>, Global>
) -> IsNull
sourceimpl<'q, T> Encode<'q, Postgres> for Vec<T, Global> where
T: Encode<'q, Postgres>,
&'a [T]: for<'a> Encode<'q, Postgres>,
impl<'q, T> Encode<'q, Postgres> for Vec<T, Global> where
T: Encode<'q, Postgres>,
&'a [T]: for<'a> Encode<'q, Postgres>,
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
sourceimpl<'_> Encode<'_, Postgres> for Vec<u8, Global>
impl<'_> Encode<'_, Postgres> for Vec<u8, Global>
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
sourceimpl<'q, T> Encode<'q, Any> for Option<T> where
T: 'q + AnyEncode<'q>,
impl<'q, T> Encode<'q, Any> for Option<T> where
T: 'q + AnyEncode<'q>,
fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull
sourceimpl<'q> Encode<'q, Sqlite> for &'q str
impl<'q> Encode<'q, Sqlite> for &'q str
fn encode_by_ref(
&self,
args: &mut Vec<SqliteArgumentValue<'q>, Global>
) -> IsNull
sourceimpl<'q, '_, T, DB> Encode<'q, DB> for &'_ T where
DB: Database,
T: Encode<'q, DB>,
impl<'q, '_, T, DB> Encode<'q, DB> for &'_ T where
DB: Database,
T: Encode<'q, DB>,
fn encode(self, buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer) -> IsNull
fn encode_by_ref(
&self,
buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer
) -> IsNull
fn produces(&self) -> Option<<DB as Database>::TypeInfo>
fn size_hint(&self) -> usize
sourceimpl<'q> Encode<'q, Any> for i64 where
i64: AnyEncode<'q>,
impl<'q> Encode<'q, Any> for i64 where
i64: AnyEncode<'q>,
fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull
sourceimpl<'q> Encode<'q, Any> for String where
String: AnyEncode<'q>,
impl<'q> Encode<'q, Any> for String where
String: AnyEncode<'q>,
fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull
sourceimpl<'_, '_> Encode<'_, Postgres> for &'_ str
impl<'_, '_> Encode<'_, Postgres> for &'_ str
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
sourceimpl<'q> Encode<'q, Any> for i32 where
i32: AnyEncode<'q>,
impl<'q> Encode<'q, Any> for i32 where
i32: AnyEncode<'q>,
fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull
sourceimpl<'_> Encode<'_, Postgres> for i32
impl<'_> Encode<'_, Postgres> for i32
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
sourceimpl<'q> Encode<'q, Sqlite> for i32
impl<'q> Encode<'q, Sqlite> for i32
fn encode_by_ref(
&self,
args: &mut Vec<SqliteArgumentValue<'q>, Global>
) -> IsNull
sourceimpl<'_> Encode<'_, Mssql> for String
impl<'_> Encode<'_, Mssql> for String
fn produces(&self) -> Option<MssqlTypeInfo>
fn encode_by_ref(&self, buf: &mut Vec<u8, Global>) -> IsNull
sourceimpl<'q> Encode<'q, Sqlite> for i64
impl<'q> Encode<'q, Sqlite> for i64
fn encode_by_ref(
&self,
args: &mut Vec<SqliteArgumentValue<'q>, Global>
) -> IsNull
sourceimpl<'_> Encode<'_, Postgres> for f32
impl<'_> Encode<'_, Postgres> for f32
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
sourceimpl<'_> Encode<'_, Postgres> for i16
impl<'_> Encode<'_, Postgres> for i16
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
sourceimpl<'q> Encode<'q, Sqlite> for u32
impl<'q> Encode<'q, Sqlite> for u32
fn encode_by_ref(
&self,
args: &mut Vec<SqliteArgumentValue<'q>, Global>
) -> IsNull
sourceimpl<'_, '_> Encode<'_, Postgres> for &'_ [u8]
impl<'_, '_> Encode<'_, Postgres> for &'_ [u8]
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
sourceimpl<'q, T> Encode<'q, Postgres> for Option<T> where
T: 'q + Encode<'q, Postgres> + Type<Postgres>,
impl<'q, T> Encode<'q, Postgres> for Option<T> where
T: 'q + Encode<'q, Postgres> + Type<Postgres>,
fn produces(&self) -> Option<<Postgres as Database>::TypeInfo>
fn encode(
self,
buf: &mut <Postgres as HasArguments<'q>>::ArgumentBuffer
) -> IsNull
fn encode_by_ref(
&self,
buf: &mut <Postgres as HasArguments<'q>>::ArgumentBuffer
) -> IsNull
fn size_hint(&self) -> usize
sourceimpl<'q, '_, T> Encode<'q, Postgres> for &'_ [T] where
T: Encode<'q, Postgres> + Type<Postgres>,
impl<'q, '_, T> Encode<'q, Postgres> for &'_ [T] where
T: Encode<'q, Postgres> + Type<Postgres>,
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
sourceimpl<'q> Encode<'q, Any> for bool where
bool: AnyEncode<'q>,
impl<'q> Encode<'q, Any> for bool where
bool: AnyEncode<'q>,
fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull
sourceimpl<'q> Encode<'q, Sqlite> for bool
impl<'q> Encode<'q, Sqlite> for bool
fn encode_by_ref(
&self,
args: &mut Vec<SqliteArgumentValue<'q>, Global>
) -> IsNull
sourceimpl<'q> Encode<'q, Sqlite> for u16
impl<'q> Encode<'q, Sqlite> for u16
fn encode_by_ref(
&self,
args: &mut Vec<SqliteArgumentValue<'q>, Global>
) -> IsNull
Implementors
impl<'_> Encode<'_, MySql> for DateTime<Local>
Note: assumes the connection’s time_zone
is set to +00:00
(UTC).
impl<'_> Encode<'_, MySql> for DateTime<Utc>
Note: assumes the connection’s time_zone
is set to +00:00
(UTC).
impl<'_> Encode<'_, MySql> for NaiveDate
impl<'_> Encode<'_, MySql> for NaiveDateTime
impl<'_> Encode<'_, MySql> for NaiveTime
impl<'_> Encode<'_, MySql> for BigDecimal
impl<'_> Encode<'_, MySql> for Decimal
impl<'_> Encode<'_, MySql> for Uuid
impl<'_> Encode<'_, MySql> for Date
impl<'_> Encode<'_, MySql> for OffsetDateTime
impl<'_> Encode<'_, MySql> for PrimitiveDateTime
impl<'_> Encode<'_, MySql> for Time
impl<'_> Encode<'_, MySql> for Hyphenated
impl<'_> Encode<'_, Postgres> for IpNetwork
impl<'_> Encode<'_, Postgres> for sqlx::postgres::types::Oid
impl<'_> Encode<'_, Postgres> for PgInterval
impl<'_> Encode<'_, Postgres> for PgLQuery
impl<'_> Encode<'_, Postgres> for PgLTree
impl<'_> Encode<'_, Postgres> for PgMoney
impl<'_> Encode<'_, Postgres> for PgTimeTz<NaiveTime, FixedOffset>
impl<'_> Encode<'_, Postgres> for PgTimeTz<Time, UtcOffset>
impl<'_> Encode<'_, Postgres> for NaiveDate
impl<'_> Encode<'_, Postgres> for NaiveDateTime
impl<'_> Encode<'_, Postgres> for NaiveTime
impl<'_> Encode<'_, Postgres> for MacAddress
impl<'_> Encode<'_, Postgres> for BigDecimal
Panics
If this BigDecimal
cannot be represented by PgNumeric
.
impl<'_> Encode<'_, Postgres> for BitVec<u32>
impl<'_> Encode<'_, Postgres> for Decimal
Panics
If this Decimal
cannot be represented by PgNumeric
.