pub trait Encode<'q, 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
where
Self: Sized,
{ ... }
fn produces(&self) -> Option<DB::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 where
Self: Sized,
fn encode(self, buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer) -> IsNull where
Self: Sized,
Writes the value of self
into buf
in the expected format for the database.
Implementations on Foreign Types
sourceimpl<'q, T, DB: Database> Encode<'q, DB> for &T where
T: Encode<'q, DB>,
impl<'q, T, DB: Database> Encode<'q, DB> for &T where
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::TypeInfo>
fn size_hint(&self) -> usize
sourceimpl<'q, DB> Encode<'q, DB> for JsonValue where
for<'a> Json<&'a Self>: Encode<'q, DB>,
DB: Database,
impl<'q, DB> Encode<'q, DB> for JsonValue where
for<'a> Json<&'a Self>: Encode<'q, DB>,
DB: Database,
fn encode_by_ref(
&self,
buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer
) -> 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, 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<'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 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, 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<'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> 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<'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
sourceimpl<'q, T> Encode<'q, Postgres> for Vec<T> where
for<'a> &'a [T]: Encode<'q, Postgres>,
T: Encode<'q, Postgres>,
impl<'q, T> Encode<'q, Postgres> for Vec<T> where
for<'a> &'a [T]: Encode<'q, Postgres>,
T: Encode<'q, Postgres>,
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
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 Encode<'_, Postgres> for bool
impl Encode<'_, Postgres> for bool
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
sourceimpl Encode<'_, Postgres> for &[u8]
impl Encode<'_, Postgres> for &[u8]
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
sourceimpl Encode<'_, Postgres> for Vec<u8>
impl Encode<'_, Postgres> for Vec<u8>
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
sourceimpl Encode<'_, Postgres> for f32
impl Encode<'_, Postgres> for f32
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
sourceimpl Encode<'_, Postgres> for f64
impl Encode<'_, Postgres> for f64
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 Encode<'_, Postgres> for i16
impl Encode<'_, Postgres> for i16
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
sourceimpl Encode<'_, Postgres> for u32
impl Encode<'_, Postgres> for u32
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
sourceimpl Encode<'_, Postgres> for i32
impl Encode<'_, Postgres> for i32
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
sourceimpl Encode<'_, Postgres> for i64
impl Encode<'_, Postgres> for i64
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> 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 Encode<'_, Postgres> for Duration
impl Encode<'_, Postgres> for Duration
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
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 Encode<'_, Postgres> for &str
impl Encode<'_, Postgres> for &str
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
sourceimpl Encode<'_, Postgres> for Cow<'_, str>
impl Encode<'_, Postgres> for Cow<'_, str>
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
sourceimpl Encode<'_, Postgres> for String
impl Encode<'_, Postgres> for String
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
sourceimpl Encode<'_, Postgres> for BigDecimal
impl Encode<'_, Postgres> for BigDecimal
Panics
If this BigDecimal
cannot be represented by PgNumeric
.
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
sourceimpl Encode<'_, Postgres> for Decimal
impl Encode<'_, Postgres> for Decimal
Panics
If this Decimal
cannot be represented by PgNumeric
.
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
sourceimpl Encode<'_, Postgres> for NaiveDate
impl Encode<'_, Postgres> for NaiveDate
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
sourceimpl Encode<'_, Postgres> for NaiveDateTime
impl Encode<'_, Postgres> for NaiveDateTime
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
sourceimpl<Tz: TimeZone> Encode<'_, Postgres> for DateTime<Tz>
impl<Tz: TimeZone> Encode<'_, Postgres> for DateTime<Tz>
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
sourceimpl Encode<'_, Postgres> for NaiveTime
impl Encode<'_, Postgres> for NaiveTime
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
sourceimpl Encode<'_, Postgres> for Date
impl Encode<'_, Postgres> for Date
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
sourceimpl Encode<'_, Postgres> for PrimitiveDateTime
impl Encode<'_, Postgres> for PrimitiveDateTime
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
sourceimpl Encode<'_, Postgres> for OffsetDateTime
impl Encode<'_, Postgres> for OffsetDateTime
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
sourceimpl Encode<'_, Postgres> for Time
impl Encode<'_, Postgres> for Time
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
sourceimpl Encode<'_, Postgres> for Uuid
impl Encode<'_, Postgres> for Uuid
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
sourceimpl Encode<'_, Postgres> for IpNetwork
impl Encode<'_, Postgres> for IpNetwork
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
sourceimpl Encode<'_, Postgres> for MacAddress
impl Encode<'_, Postgres> for MacAddress
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
sourceimpl Encode<'_, Postgres> for BitVec
impl Encode<'_, Postgres> for BitVec
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
sourceimpl<'q, T> Encode<'q, Postgres> for Option<T> where
T: Encode<'q, Postgres> + Type<Postgres> + 'q,
impl<'q, T> Encode<'q, Postgres> for Option<T> where
T: Encode<'q, Postgres> + Type<Postgres> + 'q,
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> Encode<'q, Sqlite> for bool
impl<'q> Encode<'q, Sqlite> for bool
fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> 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>>) -> IsNull
sourceimpl<'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
sourceimpl<Tz: TimeZone> Encode<'_, Sqlite> for DateTime<Tz> where
Tz::Offset: Display,
impl<Tz: TimeZone> Encode<'_, Sqlite> for DateTime<Tz> where
Tz::Offset: Display,
fn encode_by_ref(&self, buf: &mut Vec<SqliteArgumentValue<'_>>) -> IsNull
sourceimpl Encode<'_, Sqlite> for NaiveDateTime
impl Encode<'_, Sqlite> for NaiveDateTime
fn encode_by_ref(&self, buf: &mut Vec<SqliteArgumentValue<'_>>) -> IsNull
sourceimpl Encode<'_, Sqlite> for NaiveDate
impl Encode<'_, Sqlite> for NaiveDate
fn encode_by_ref(&self, buf: &mut Vec<SqliteArgumentValue<'_>>) -> IsNull
sourceimpl Encode<'_, Sqlite> for NaiveTime
impl Encode<'_, Sqlite> for NaiveTime
fn encode_by_ref(&self, buf: &mut Vec<SqliteArgumentValue<'_>>) -> 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>>) -> 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>>) -> IsNull
sourceimpl<'q> Encode<'q, Sqlite> for i8
impl<'q> Encode<'q, Sqlite> for i8
fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'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>>) -> 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>>) -> 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>>) -> 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>>) -> IsNull
sourceimpl<'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
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>>) -> IsNull
fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> 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>>) -> 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>>) -> 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>>) -> IsNull
sourceimpl<'q> Encode<'q, Sqlite> for Uuid
impl<'q> Encode<'q, Sqlite> for Uuid
fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull
sourceimpl<'q> Encode<'q, Sqlite> for Hyphenated
impl<'q> Encode<'q, Sqlite> for Hyphenated
fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull
sourceimpl<'q, T> Encode<'q, Sqlite> for Option<T> where
T: Encode<'q, Sqlite> + Type<Sqlite> + 'q,
impl<'q, T> Encode<'q, Sqlite> for Option<T> where
T: Encode<'q, Sqlite> + Type<Sqlite> + 'q,
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 Encode<'_, MySql> for Cow<'_, str>
impl Encode<'_, MySql> for Cow<'_, str>
fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull
sourceimpl Encode<'_, MySql> for BigDecimal
impl Encode<'_, MySql> for BigDecimal
fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull
sourceimpl Encode<'_, MySql> for DateTime<Utc>
impl Encode<'_, MySql> for DateTime<Utc>
Note: assumes the connection’s time_zone
is set to +00:00
(UTC).
fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull
sourceimpl Encode<'_, MySql> for DateTime<Local>
impl Encode<'_, MySql> for DateTime<Local>
Note: assumes the connection’s time_zone
is set to +00:00
(UTC).