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
Dyn Compatibilityยง
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Typesยง
Sourceยงimpl Encode<'_, Mssql> for BigDecimal
impl Encode<'_, Mssql> for BigDecimal
Sourceยงimpl Encode<'_, Mssql> for NaiveDateTime
Encodes DateTime objects for transfer over the wire
impl Encode<'_, Mssql> for NaiveDateTime
Encodes DateTime objects for transfer over the wire
Sourceยงimpl Encode<'_, MySql> for BigDecimal
impl Encode<'_, MySql> for BigDecimal
Sourceยงimpl Encode<'_, MySql> for DateTime<Local>
Note: assumes the connectionโs time_zone is set to +00:00 (UTC).
impl Encode<'_, MySql> for DateTime<Local>
Note: assumes the connectionโs time_zone is set to +00:00 (UTC).
Sourceยงimpl Encode<'_, MySql> for DateTime<Utc>
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).
Sourceยงimpl Encode<'_, MySql> for Hyphenated
impl Encode<'_, MySql> for Hyphenated
Sourceยงimpl Encode<'_, MySql> for NaiveDateTime
impl Encode<'_, MySql> for NaiveDateTime
Sourceยงimpl Encode<'_, MySql> for OffsetDateTime
impl Encode<'_, MySql> for OffsetDateTime
Sourceยงimpl Encode<'_, MySql> for PrimitiveDateTime
impl Encode<'_, MySql> for PrimitiveDateTime
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 &str
impl Encode<'_, Postgres> for &str
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
Sourceยงimpl Encode<'_, Postgres> for BigDecimal
ยงPanics
If this BigDecimal cannot be represented by PgNumeric.
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
Sourceยงimpl Encode<'_, Postgres> for BitVec
impl Encode<'_, Postgres> for BitVec
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
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 Date
impl Encode<'_, Postgres> for Date
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
Sourceยงimpl Encode<'_, Postgres> for Decimal
ยงPanics
If this Decimal cannot be represented by PgNumeric.
impl Encode<'_, Postgres> for Decimal
ยงPanics
If this Decimal cannot be represented by PgNumeric.
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 Duration
Available on crate feature time only.
impl Encode<'_, Postgres> for Duration
Available on crate feature
time only.fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
Sourceยงimpl Encode<'_, Postgres> for IpNetwork
impl Encode<'_, Postgres> for IpNetwork
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
Sourceยงimpl Encode<'_, Postgres> for MacAddress
impl Encode<'_, Postgres> for MacAddress
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
Sourceยงimpl Encode<'_, Postgres> for NaiveDate
impl Encode<'_, Postgres> for NaiveDate
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
Sourceยงimpl Encode<'_, Postgres> for NaiveDateTime
impl Encode<'_, Postgres> for NaiveDateTime
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
Sourceยงimpl Encode<'_, Postgres> for NaiveTime
impl Encode<'_, Postgres> for NaiveTime
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
Sourceยงimpl Encode<'_, Postgres> for OffsetDateTime
impl Encode<'_, Postgres> for OffsetDateTime
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
Sourceยงimpl Encode<'_, Postgres> for PrimitiveDateTime
impl Encode<'_, Postgres> for PrimitiveDateTime
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
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 Time
impl Encode<'_, Postgres> for Time
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
Sourceยงimpl Encode<'_, Postgres> for TimeDelta
Available on crate feature chrono only.
impl Encode<'_, Postgres> for TimeDelta
Available on crate feature
chrono only.