Trait sqlx_core_oldapi::encode::Encode
source · pub trait Encode<'q, 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::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::TypeInfo>
fn size_hint(&self) -> usize
Implementations on Foreign Types§
source§impl Encode<'_, Mssql> for BigDecimal
impl Encode<'_, Mssql> for BigDecimal
source§impl Encode<'_, Mssql> for NaiveDateTime
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>
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>
impl Encode<'_, MySql> for DateTime<Utc>
Note: assumes the connection’s time_zone
is set to +00:00
(UTC).
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<'_, MySql> for Hyphenated
impl Encode<'_, MySql> for Hyphenated
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 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 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 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 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
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 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 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 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 Decimal
impl Encode<'_, Postgres> for Decimal
Panics
If this Decimal
cannot be represented by PgNumeric
.