pub trait Encode<'q, DB>where
DB: Database,{
// Required method
fn encode_by_ref(
&self,
buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer,
) -> IsNull;
// Provided methods
fn encode(
self,
buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer,
) -> IsNull
where Self: Sized { ... }
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ยง
Sourcefn 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ยง
Sourcefn encode(self, buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer) -> IsNullwhere
Self: Sized,
fn encode(self, buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer) -> IsNullwhere
Self: Sized,
Writes the value of self
into buf
in the expected format for the database.
fn produces(&self) -> Option<<DB as Database>::TypeInfo>
fn size_hint(&self) -> usize
Implementations on Foreign Typesยง
Sourceยงimpl Encode<'_, Postgres> for &str
impl Encode<'_, Postgres> for &str
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
Sourceยงimpl Encode<'_, Postgres> for &[u8]
impl Encode<'_, Postgres> for &[u8]
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
Sourceยงimpl Encode<'_, Postgres> for Cow<'_, str>
impl Encode<'_, Postgres> for Cow<'_, str>
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
Sourceยงimpl Encode<'_, Postgres> for bool
impl Encode<'_, Postgres> for bool
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
Sourceยงimpl Encode<'_, Postgres> for f32
impl Encode<'_, Postgres> for f32
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
Sourceยงimpl Encode<'_, Postgres> for f64
impl Encode<'_, Postgres> for f64
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
Sourceยงimpl Encode<'_, Postgres> for i8
impl Encode<'_, Postgres> for i8
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
Sourceยงimpl Encode<'_, Postgres> for i16
impl Encode<'_, Postgres> for i16
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
Sourceยงimpl Encode<'_, Postgres> for i32
impl Encode<'_, Postgres> for i32
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
Sourceยงimpl Encode<'_, Postgres> for i64
impl Encode<'_, Postgres> for i64
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
Sourceยงimpl Encode<'_, Postgres> for u16
impl Encode<'_, Postgres> for u16
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
Sourceยงimpl Encode<'_, Postgres> for u32
impl Encode<'_, Postgres> for u32
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
Sourceยงimpl Encode<'_, Postgres> for u64
impl Encode<'_, Postgres> for u64
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
Sourceยงimpl Encode<'_, Postgres> for String
impl Encode<'_, Postgres> for String
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
Sourceยงimpl Encode<'_, Postgres> for Vec<u8>
impl Encode<'_, Postgres> for Vec<u8>
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
Sourceยงimpl Encode<'_, Postgres> for Duration
impl Encode<'_, Postgres> for Duration
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
Sourceยงimpl Encode<'_, Postgres> for TimeDelta
impl Encode<'_, Postgres> for TimeDelta
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
Sourceยงimpl Encode<'_, Postgres> for Duration
impl Encode<'_, Postgres> for Duration
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
Sourceยงimpl<'db> Encode<'db, Postgres> for IpAddr
impl<'db> Encode<'db, Postgres> for IpAddr
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
Sourceยงimpl<'q> Encode<'q, Any> for &'q str
impl<'q> Encode<'q, Any> for &'q str
fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull
Sourceยงimpl<'q> Encode<'q, Any> for &'q [u8]
impl<'q> Encode<'q, Any> for &'q [u8]
fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull
Sourceยงimpl<'q> Encode<'q, Any> for bool
impl<'q> Encode<'q, Any> for bool
fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull
Sourceยงimpl<'q> Encode<'q, Any> for f32
impl<'q> Encode<'q, Any> for f32
fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull
Sourceยงimpl<'q> Encode<'q, Any> for f64
impl<'q> Encode<'q, Any> for f64
fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull
Sourceยงimpl<'q> Encode<'q, Any> for i16
impl<'q> Encode<'q, Any> for i16
fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull
Sourceยงimpl<'q> Encode<'q, Any> for i32
impl<'q> Encode<'q, Any> for i32
fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull
Sourceยงimpl<'q> Encode<'q, Any> for i64
impl<'q> Encode<'q, Any> for i64
fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull
Sourceยงimpl<'q> Encode<'q, Any> for u16
impl<'q> Encode<'q, Any> for u16
fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull
Sourceยงimpl<'q> Encode<'q, Any> for u32
impl<'q> Encode<'q, Any> for u32
fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull
Sourceยงimpl<'q> Encode<'q, Any> for u64
impl<'q> Encode<'q, Any> for u64
fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull
Sourceยงimpl<'q> Encode<'q, Any> for String
impl<'q> Encode<'q, Any> for String
fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull
Sourceยงimpl<'q> Encode<'q, Any> for Vec<u8>
impl<'q> Encode<'q, Any> for Vec<u8>
fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull
Sourceยงimpl<'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>>) -> IsNull
Sourceยงimpl<'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>>) -> IsNull
Sourceยงimpl<'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>>) -> IsNull
fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull
Sourceยงimpl<'q> Encode<'q, Sqlite> for bool
impl<'q> Encode<'q, Sqlite> for bool
fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull
Sourceยงimpl<'q> Encode<'q, Sqlite> for f32
impl<'q> Encode<'q, Sqlite> for f32
fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull
Sourceยงimpl<'q> Encode<'q, Sqlite> for f64
impl<'q> Encode<'q, Sqlite> for f64
fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull
Sourceยงimpl<'q> Encode<'q, Sqlite> for i8
impl<'q> Encode<'q, Sqlite> for i8
fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull
Sourceยงimpl<'q> Encode<'q, Sqlite> for i16
impl<'q> Encode<'q, Sqlite> for i16
fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull
Sourceยงimpl<'q> Encode<'q, Sqlite> for i32
impl<'q> Encode<'q, Sqlite> for i32
fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull
Sourceยงimpl<'q> Encode<'q, Sqlite> for i64
impl<'q> Encode<'q, Sqlite> for i64
fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull
Sourceยงimpl<'q> Encode<'q, Sqlite> for u8
impl<'q> Encode<'q, Sqlite> for u8
fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull
Sourceยงimpl<'q> Encode<'q, Sqlite> for u16
impl<'q> Encode<'q, Sqlite> for u16
fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull
Sourceยงimpl<'q> Encode<'q, Sqlite> for u32
impl<'q> Encode<'q, Sqlite> for u32
fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull
Sourceยงimpl<'q> Encode<'q, Sqlite> for u64
impl<'q> Encode<'q, Sqlite> for u64
fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull
Sourceยงimpl<'q> Encode<'q, Sqlite> for String
impl<'q> Encode<'q, Sqlite> for String
fn encode(self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull
fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull
Sourceยงimpl<'q> Encode<'q, Sqlite> for Vec<u8>
impl<'q> Encode<'q, Sqlite> for Vec<u8>
fn encode(self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull
fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull
Sourceยงimpl<'q, T> Encode<'q, Any> for Option<T>where
T: AnyEncode<'q> + 'q,
impl<'q, T> Encode<'q, Any> for Option<T>where
T: AnyEncode<'q> + 'q,
fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull
Sourceยงimpl<'q, T> Encode<'q, MySql> for Option<T>
impl<'q, T> Encode<'q, MySql> for Option<T>
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
Sourceยงimpl<'q, T> Encode<'q, Postgres> for &[T]
impl<'q, T> Encode<'q, Postgres> for &[T]
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
Sourceยงimpl<'q, T> Encode<'q, Postgres> for Option<T>
impl<'q, T> Encode<'q, Postgres> for Option<T>
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
Sourceยงimpl<'q, T> Encode<'q, Postgres> for Vec<T>
impl<'q, T> Encode<'q, Postgres> for Vec<T>
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
Sourceยงimpl<'q, T> Encode<'q, Sqlite> for Option<T>
impl<'q, T> Encode<'q, Sqlite> for Option<T>
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
Sourceยงimpl<'q, T, DB> Encode<'q, DB> for &T
impl<'q, T, DB> Encode<'q, DB> for &T
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
Sourceยงimpl<'q, T, const N: usize> Encode<'q, Postgres> for [T; N]
impl<'q, T, const N: usize> Encode<'q, Postgres> for [T; N]
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
Sourceยงimpl<const N: usize> Encode<'_, Postgres> for [u8; N]
impl<const N: usize> Encode<'_, Postgres> for [u8; N]
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
Implementorsยง
impl Encode<'_, Mssql> for NaiveDate
Encodes Date objects for transfer over the wire
impl Encode<'_, Mssql> for NaiveDateTime
Encodes DateTime objects for transfer over the wire
impl Encode<'_, Mssql> for NaiveTime
Encodes Time objects for transfer over the wire
impl Encode<'_, Mssql> for BigDecimal
impl Encode<'_, Mssql> for Decimal
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_oldapi::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
impl Encode<'_, Postgres> for PgTimeTz<NaiveTime, FixedOffset>
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
impl Encode<'_, Postgres> for Decimal
ยงPanics
If this Decimal
cannot be represented by PgNumeric
.