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
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
sourceimpl<'q, T, DB: Database> Encode<'q, DB> for &Twhere
T: Encode<'q, DB>,
impl<'q, T, DB: Database> Encode<'q, DB> for &Twhere
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, 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, const N: usize> Encode<'q, Postgres> for [T; N]where
for<'a> &'a [T]: Encode<'q, Postgres>,
T: Encode<'q, Postgres>,
impl<'q, T, const N: usize> Encode<'q, Postgres> for [T; N]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<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
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 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 &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.