sqlx

Trait Encode

source
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§

source

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§

source

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.

source

fn produces(&self) -> Option<<DB as Database>::TypeInfo>

source

fn size_hint(&self) -> usize

Implementations on Foreign Types§

source§

impl Encode<'_, MySql> for &str

source§

fn encode_by_ref( &self, buf: &mut Vec<u8>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, MySql> for &[u8]

source§

fn encode_by_ref( &self, buf: &mut Vec<u8>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, MySql> for Cow<'_, str>

source§

fn encode_by_ref( &self, buf: &mut Vec<u8>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, MySql> for IpAddr

source§

fn encode_by_ref( &self, buf: &mut Vec<u8>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, MySql> for bool

source§

fn encode_by_ref( &self, buf: &mut Vec<u8>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, MySql> for f32

source§

fn encode_by_ref( &self, buf: &mut Vec<u8>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, MySql> for f64

source§

fn encode_by_ref( &self, buf: &mut Vec<u8>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, MySql> for i8

source§

fn encode_by_ref( &self, buf: &mut Vec<u8>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, MySql> for i16

source§

fn encode_by_ref( &self, buf: &mut Vec<u8>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, MySql> for i32

source§

fn encode_by_ref( &self, buf: &mut Vec<u8>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, MySql> for i64

source§

fn encode_by_ref( &self, buf: &mut Vec<u8>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, MySql> for u8

source§

fn encode_by_ref( &self, buf: &mut Vec<u8>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, MySql> for u16

source§

fn encode_by_ref( &self, buf: &mut Vec<u8>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, MySql> for u32

source§

fn encode_by_ref( &self, buf: &mut Vec<u8>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, MySql> for u64

source§

fn encode_by_ref( &self, buf: &mut Vec<u8>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, MySql> for Box<str>

source§

fn encode_by_ref( &self, buf: &mut Vec<u8>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, MySql> for Box<[u8]>

source§

fn encode_by_ref( &self, buf: &mut Vec<u8>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, MySql> for String

source§

fn encode_by_ref( &self, buf: &mut Vec<u8>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, MySql> for Vec<u8>

source§

fn encode_by_ref( &self, buf: &mut Vec<u8>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, MySql> for Ipv4Addr

source§

fn encode_by_ref( &self, buf: &mut Vec<u8>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, MySql> for Ipv6Addr

source§

fn encode_by_ref( &self, buf: &mut Vec<u8>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, Postgres> for &str

source§

fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, Postgres> for &[u8]

source§

fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, Postgres> for Cow<'_, str>

source§

fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, Postgres> for bool

source§

fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, Postgres> for f32

source§

fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, Postgres> for f64

source§

fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, Postgres> for i8

source§

fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, Postgres> for i16

source§

fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, Postgres> for i32

source§

fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, Postgres> for i64

source§

fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, Postgres> for TimeDelta

source§

fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

fn size_hint(&self) -> usize

source§

impl Encode<'_, Postgres> for Duration

source§

fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

fn size_hint(&self) -> usize

source§

impl Encode<'_, Postgres> for Box<str>

source§

fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, Postgres> for Box<[u8]>

source§

fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, Postgres> for String

source§

fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, Postgres> for Vec<u8>

source§

fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl Encode<'_, Postgres> for Duration

source§

fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

fn size_hint(&self) -> usize

source§

impl<'a> Encode<'a, Any> for &'a str

source§

fn encode( self, buf: &mut <Any as Database>::ArgumentBuffer<'a>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
where &'a str: Sized,

source§

fn encode_by_ref( &self, buf: &mut <Any as Database>::ArgumentBuffer<'a>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl<'q> Encode<'q, Any> for &'q [u8]

source§

fn encode_by_ref( &self, buf: &mut <Any as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl<'q> Encode<'q, Any> for bool

source§

fn encode_by_ref( &self, buf: &mut <Any as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl<'q> Encode<'q, Any> for f32

source§

fn encode_by_ref( &self, buf: &mut AnyArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl<'q> Encode<'q, Any> for f64

source§

fn encode_by_ref( &self, buf: &mut <Any as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl<'q> Encode<'q, Any> for i16

source§

fn encode_by_ref( &self, buf: &mut <Any as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl<'q> Encode<'q, Any> for i32

source§

fn encode_by_ref( &self, buf: &mut <Any as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl<'q> Encode<'q, Any> for i64

source§

fn encode_by_ref( &self, buf: &mut <Any as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl<'q> Encode<'q, Any> for String

source§

fn encode_by_ref( &self, buf: &mut <Any as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl<'q> Encode<'q, Any> for Vec<u8>

source§

fn encode_by_ref( &self, buf: &mut <Any as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

impl<'q, DB> Encode<'q, DB> for NonZero<i8>
where DB: Database, i8: Encode<'q, DB>,

source§

fn encode_by_ref( &self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

fn encode( self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
where NonZero<i8>: Sized,

source§

fn produces(&self) -> Option<<DB as Database>::TypeInfo>

source§

impl<'q, DB> Encode<'q, DB> for NonZero<i16>
where DB: Database, i16: Encode<'q, DB>,

source§

fn encode_by_ref( &self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

fn encode( self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
where NonZero<i16>: Sized,

source§

fn produces(&self) -> Option<<DB as Database>::TypeInfo>

source§

impl<'q, DB> Encode<'q, DB> for NonZero<i32>
where DB: Database, i32: Encode<'q, DB>,

source§

fn encode_by_ref( &self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

fn encode( self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
where NonZero<i32>: Sized,

source§

fn produces(&self) -> Option<<DB as Database>::TypeInfo>

source§

impl<'q, DB> Encode<'q, DB> for NonZero<i64>
where DB: Database, i64: Encode<'q, DB>,

source§

fn encode_by_ref( &self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

fn encode( self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
where NonZero<i64>: Sized,

source§

fn produces(&self) -> Option<<DB as Database>::TypeInfo>

source§

impl<'q, DB> Encode<'q, DB> for NonZero<u8>
where DB: Database, u8: Encode<'q, DB>,

source§

fn encode_by_ref( &self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

fn encode( self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
where NonZero<u8>: Sized,

source§

fn produces(&self) -> Option<<DB as Database>::TypeInfo>

source§

impl<'q, DB> Encode<'q, DB> for NonZero<u16>
where DB: Database, u16: Encode<'q, DB>,

source§

fn encode_by_ref( &self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

fn encode( self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
where NonZero<u16>: Sized,

source§

fn produces(&self) -> Option<<DB as Database>::TypeInfo>

source§

impl<'q, DB> Encode<'q, DB> for NonZero<u32>
where DB: Database, u32: Encode<'q, DB>,

source§

fn encode_by_ref( &self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

fn encode( self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
where NonZero<u32>: Sized,

source§

fn produces(&self) -> Option<<DB as Database>::TypeInfo>

source§

impl<'q, DB> Encode<'q, DB> for NonZero<u64>
where DB: Database, u64: Encode<'q, DB>,

source§

fn encode_by_ref( &self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

fn encode( self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
where NonZero<u64>: Sized,

source§

fn produces(&self) -> Option<<DB as Database>::TypeInfo>

source§

impl<'q, T> Encode<'q, Any> for Option<T>
where T: Encode<'q, Any> + 'q + Type<Any>,

source§

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>
where T: Encode<'q, MySql> + Type<MySql> + 'q,

source§

fn produces(&self) -> Option<<MySql as Database>::TypeInfo>

source§

fn encode( self, buf: &mut <MySql as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

fn encode_by_ref( &self, buf: &mut <MySql as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

fn size_hint(&self) -> usize

source§

impl<'q, T> Encode<'q, Postgres> for &[T]
where T: Encode<'q, Postgres> + Type<Postgres>,

source§

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>
where T: Encode<'q, Postgres> + Type<Postgres> + 'q,

source§

fn produces(&self) -> Option<<Postgres as Database>::TypeInfo>

source§

fn encode( self, buf: &mut <Postgres as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

fn encode_by_ref( &self, buf: &mut <Postgres as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

fn size_hint(&self) -> usize

source§

impl<'q, T> Encode<'q, Postgres> for Vec<T>
where &'a [T]: for<'a> Encode<'q, Postgres>, T: Encode<'q, Postgres>,

source§

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
where DB: Database, T: Encode<'q, DB>,

source§

fn encode( self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

fn encode_by_ref( &self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

source§

fn produces(&self) -> Option<<DB as Database>::TypeInfo>

source§

fn size_hint(&self) -> usize

source§

impl<'q, T, const N: usize> Encode<'q, Postgres> for [T; N]
where &'a [T]: for<'a> Encode<'q, Postgres>, T: Encode<'q, Postgres>,

source§

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]

source§

fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

Implementors§

source§

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).

source§

impl Encode<'_, MySql> for NaiveDate

source§

impl Encode<'_, MySql> for NaiveDateTime

source§

impl Encode<'_, MySql> for NaiveTime

source§

impl Encode<'_, MySql> for Decimal

source§

impl Encode<'_, MySql> for Uuid

source§

impl Encode<'_, MySql> for Date

source§

impl Encode<'_, MySql> for OffsetDateTime

source§

impl Encode<'_, MySql> for PrimitiveDateTime

source§

impl Encode<'_, MySql> for Time

source§

impl Encode<'_, MySql> for Hyphenated

source§

impl Encode<'_, MySql> for Simple

source§

impl Encode<'_, Postgres> for Oid

source§

impl Encode<'_, Postgres> for PgCiText

source§

impl Encode<'_, Postgres> for PgHstore

source§

impl Encode<'_, Postgres> for PgInterval

source§

impl Encode<'_, Postgres> for PgLQuery

source§

impl Encode<'_, Postgres> for PgLTree

source§

impl Encode<'_, Postgres> for PgMoney

source§

impl Encode<'_, Postgres> for PgTimeTz

source§

impl Encode<'_, Postgres> for PgTimeTz<NaiveTime, FixedOffset>

source§

impl Encode<'_, Postgres> for NaiveDate

source§

impl Encode<'_, Postgres> for NaiveDateTime

source§

impl Encode<'_, Postgres> for NaiveTime

source§

impl Encode<'_, Postgres> for Decimal

source§

impl Encode<'_, Postgres> for Uuid

source§

impl Encode<'_, Postgres> for Date

source§

impl Encode<'_, Postgres> for OffsetDateTime

source§

impl Encode<'_, Postgres> for PrimitiveDateTime

source§

impl Encode<'_, Postgres> for Time

source§

impl<'q> Encode<'q, MySql> for MySqlTime

source§

impl<'q> Encode<'q, Postgres> for PgCube

source§

impl<'q, DB> Encode<'q, DB> for Value
where Json<&'a Value>: for<'a> Encode<'q, DB>, DB: Database,

source§

impl<'q, T> Encode<'q, MySql> for Text<T>
where T: Display,

source§

impl<'q, T> Encode<'q, Postgres> for PgRange<T>
where T: Encode<'q, Postgres>,

source§

impl<'q, T> Encode<'q, Postgres> for Json<T>
where T: Serialize,

source§

impl<'q, T> Encode<'q, Postgres> for Text<T>
where T: Display,

source§

impl<T> Encode<'_, MySql> for Json<T>
where T: Serialize,

source§

impl<Tz> Encode<'_, Postgres> for DateTime<Tz>
where Tz: TimeZone,