pub trait Encode<'q, DB>where
DB: Database,{
// Required method
fn encode_by_ref(
&self,
buf: &mut <DB as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>;
// Provided methods
fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>
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 Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn encode_by_ref( &self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
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 Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
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, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
source§impl Encode<'_, Postgres> for &[u8]
impl Encode<'_, Postgres> for &[u8]
fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
source§impl Encode<'_, Postgres> for Cow<'_, str>
impl Encode<'_, Postgres> for Cow<'_, str>
fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
source§impl Encode<'_, Postgres> for bool
impl Encode<'_, Postgres> for bool
fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
source§impl Encode<'_, Postgres> for f32
impl Encode<'_, Postgres> for f32
fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
source§impl Encode<'_, Postgres> for f64
impl Encode<'_, Postgres> for f64
fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
source§impl Encode<'_, Postgres> for i8
impl Encode<'_, Postgres> for i8
fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
source§impl Encode<'_, Postgres> for i16
impl Encode<'_, Postgres> for i16
fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
source§impl Encode<'_, Postgres> for i32
impl Encode<'_, Postgres> for i32
fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
source§impl Encode<'_, Postgres> for i64
impl Encode<'_, Postgres> for i64
fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
source§impl Encode<'_, Postgres> for Box<str>
impl Encode<'_, Postgres> for Box<str>
fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
source§impl Encode<'_, Postgres> for Box<[u8]>
impl Encode<'_, Postgres> for Box<[u8]>
fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
source§impl Encode<'_, Postgres> for String
impl Encode<'_, Postgres> for String
fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
source§impl Encode<'_, Postgres> for Vec<u8>
impl Encode<'_, Postgres> for Vec<u8>
fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
source§impl<'q> Encode<'q, Any> for f32
impl<'q> Encode<'q, Any> for f32
fn encode_by_ref( &self, buf: &mut AnyArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
source§impl<'q, DB> Encode<'q, DB> for NonZero<i8>
impl<'q, DB> Encode<'q, DB> for NonZero<i8>
fn encode_by_ref( &self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn encode( self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn produces(&self) -> Option<<DB as Database>::TypeInfo>
source§impl<'q, DB> Encode<'q, DB> for NonZero<i16>
impl<'q, DB> Encode<'q, DB> for NonZero<i16>
fn encode_by_ref( &self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn encode( self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn produces(&self) -> Option<<DB as Database>::TypeInfo>
source§impl<'q, DB> Encode<'q, DB> for NonZero<i32>
impl<'q, DB> Encode<'q, DB> for NonZero<i32>
fn encode_by_ref( &self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn encode( self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn produces(&self) -> Option<<DB as Database>::TypeInfo>
source§impl<'q, DB> Encode<'q, DB> for NonZero<i64>
impl<'q, DB> Encode<'q, DB> for NonZero<i64>
fn encode_by_ref( &self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn encode( self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn produces(&self) -> Option<<DB as Database>::TypeInfo>
source§impl<'q, DB> Encode<'q, DB> for NonZero<u8>
impl<'q, DB> Encode<'q, DB> for NonZero<u8>
fn encode_by_ref( &self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn encode( self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn produces(&self) -> Option<<DB as Database>::TypeInfo>
source§impl<'q, DB> Encode<'q, DB> for NonZero<u16>
impl<'q, DB> Encode<'q, DB> for NonZero<u16>
fn encode_by_ref( &self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn encode( self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn produces(&self) -> Option<<DB as Database>::TypeInfo>
source§impl<'q, DB> Encode<'q, DB> for NonZero<u32>
impl<'q, DB> Encode<'q, DB> for NonZero<u32>
fn encode_by_ref( &self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn encode( self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn produces(&self) -> Option<<DB as Database>::TypeInfo>
source§impl<'q, DB> Encode<'q, DB> for NonZero<u64>
impl<'q, DB> Encode<'q, DB> for NonZero<u64>
fn encode_by_ref( &self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn encode( self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn produces(&self) -> Option<<DB as Database>::TypeInfo>
source§impl<'q, T> Encode<'q, Any> for Option<T>
impl<'q, T> Encode<'q, Any> for Option<T>
fn encode_by_ref( &self, buf: &mut AnyArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
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 Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn encode_by_ref( &self, buf: &mut <MySql as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
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, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
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 Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn encode_by_ref( &self, buf: &mut <Postgres as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
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, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
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 Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn encode_by_ref( &self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
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, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
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, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
Implementors§
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).