Trait sqlx_core::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§

source

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§

source

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.

source

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

source

fn size_hint(&self) -> usize

Implementations on Foreign Types§

source§

impl Encode<'_, MySql> for i8

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

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

source§

fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull

source§

impl<'q> Encode<'q, Sqlite> for &'q str

source§

fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull

source§

impl Encode<'_, Sqlite> for OffsetDateTime

source§

impl Encode<'_, Mssql> for i64

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

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

source§

fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull

source§

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

source§

fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull

source§

impl<'q> Encode<'q, Any> for Stringwhere String: AnyEncode<'q>,

source§

fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull

source§

impl Encode<'_, MySql> for i64

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

impl Encode<'_, Postgres> for bool

source§

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

source§

fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull

source§

impl<'q> Encode<'q, Sqlite> for Hyphenated

source§

fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull

source§

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

source§

impl Encode<'_, Mssql> for f32

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

impl Encode<'_, MySql> for OffsetDateTime

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

impl Encode<'_, Postgres> for f32

source§

impl<'q> Encode<'q, Sqlite> for i8

source§

fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull

source§

impl Encode<'_, MySql> for Time

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

fn size_hint(&self) -> usize

source§

impl Encode<'_, MySql> for Hyphenated

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

impl Encode<'_, Mssql> for bool

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

impl Encode<'_, MySql> for Uuid

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

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

source§

fn encode(self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull

source§

fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull

source§

impl<'db> Encode<'db, Postgres> for IpAddrwhere IpNetwork: Encode<'db, Postgres>,

source§

impl Encode<'_, Postgres> for String

source§

impl<'q> Encode<'q, Sqlite> for u8

source§

fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull

source§

impl Encode<'_, MySql> for String

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

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

source§

fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull

source§

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

source§

impl Encode<'_, Mssql> for String

source§

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

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

impl Encode<'_, MySql> for DateTime<Utc>

Note: assumes the connection’s time_zone is set to +00:00 (UTC).

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

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

source§

impl Encode<'_, Postgres> for BigDecimal

Panics

If this BigDecimal cannot be represented by PgNumeric.

source§

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

source§

impl Encode<'_, MySql> for NaiveTime

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

fn size_hint(&self) -> usize

source§

impl Encode<'_, Postgres> for Date

source§

impl Encode<'_, Postgres> for i8

source§

impl Encode<'_, Postgres> for BitVec

source§

impl Encode<'_, Postgres> for &str

source§

impl Encode<'_, Postgres> for NaiveTime

source§

impl Encode<'_, Mssql> for u8

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

impl Encode<'_, MySql> for f64

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

impl Encode<'_, Mssql> for i32

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

impl<'q> Encode<'q, Any> for i32where i32: AnyEncode<'q>,

source§

fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull

source§

impl Encode<'_, Sqlite> for PrimitiveDateTime

source§

impl Encode<'_, MySql> for u16

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

impl Encode<'_, MySql> for bool

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

impl Encode<'_, Sqlite> for NaiveDateTime

source§

impl Encode<'_, Postgres> for NaiveDate

source§

impl<const N: usize> Encode<'_, Postgres> for [u8; N]

source§

impl Encode<'_, Mssql> for f64

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

impl<'q> Encode<'q, Any> for boolwhere bool: AnyEncode<'q>,

source§

fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull

source§

impl<'q> Encode<'q, Any> for f64where f64: AnyEncode<'q>,

source§

fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull

source§

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

source§

impl Encode<'_, Postgres> for PrimitiveDateTime

source§

impl Encode<'_, MySql> for NaiveDateTime

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

fn size_hint(&self) -> usize

source§

impl Encode<'_, MySql> for f32

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

impl<Tz: TimeZone> Encode<'_, Sqlite> for DateTime<Tz>where Tz::Offset: Display,

source§

impl Encode<'_, MySql> for Decimal

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

impl Encode<'_, MySql> for u8

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

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

source§

impl Encode<'_, Mssql> for &str

source§

impl Encode<'_, Sqlite> for Date

source§

impl Encode<'_, Postgres> for Time

source§

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

source§

impl Encode<'_, MySql> for BigDecimal

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

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

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

impl Encode<'_, Sqlite> for NaiveTime

source§

impl Encode<'_, Mssql> for i16

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

impl Encode<'_, MySql> for i32

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

impl Encode<'_, Postgres> for Decimal

Panics

If this Decimal cannot be represented by PgNumeric.

source§

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

source§

fn encode(self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull

source§

fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull

source§

impl<'q, T: 'q + Encode<'q, Mssql>> Encode<'q, Mssql> for Option<T>

source§

fn encode(self, buf: &mut Vec<u8>) -> IsNull

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

fn produces(&self) -> Option<MssqlTypeInfo>

source§

fn size_hint(&self) -> usize

source§

impl<'q> Encode<'q, Any> for i16where i16: AnyEncode<'q>,

source§

fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull

source§

impl Encode<'_, Sqlite> for NaiveDate

source§

impl<'q> Encode<'q, Any> for f32where f32: AnyEncode<'q>,

source§

fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull

source§

impl Encode<'_, MySql> for NaiveDate

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

fn size_hint(&self) -> usize

source§

impl<'q> Encode<'q, Sqlite> for Uuid

source§

fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull

source§

impl Encode<'_, Postgres> for MacAddress

source§

impl Encode<'_, Postgres> for Duration

source§

impl<'q> Encode<'q, Any> for &'q strwhere &'q str: AnyEncode<'q>,

source§

fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull

source§

impl Encode<'_, MySql> for PrimitiveDateTime

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

fn size_hint(&self) -> usize

source§

impl Encode<'_, MySql> for DateTime<Local>

Note: assumes the connection’s time_zone is set to +00:00 (UTC).

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

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

source§

impl Encode<'_, Postgres> for NaiveDateTime

source§

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

source§

fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull

source§

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

source§

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

source§

impl Encode<'_, Postgres> for i16

source§

impl<'q> Encode<'q, Sqlite> for Cow<'q, str>

source§

fn encode(self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull

source§

fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull

source§

impl<'q> Encode<'q, Any> for i64where i64: AnyEncode<'q>,

source§

fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull

source§

impl Encode<'_, Postgres> for Duration

source§

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

source§

fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull

source§

impl Encode<'_, Sqlite> for Time

source§

impl Encode<'_, Postgres> for Uuid

source§

impl Encode<'_, Postgres> for IpNetwork

source§

impl Encode<'_, MySql> for i16

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

impl Encode<'_, MySql> for u64

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

impl Encode<'_, Postgres> for OffsetDateTime

source§

impl<'q> Encode<'q, Sqlite> for u16

source§

fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull

source§

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

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

impl Encode<'_, Postgres> for f64

source§

impl Encode<'_, Postgres> for i64

source§

impl Encode<'_, Postgres> for i32

source§

impl Encode<'_, Mssql> for i8

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

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

source§

impl Encode<'_, MySql> for Date

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

fn size_hint(&self) -> usize

source§

impl Encode<'_, Postgres> for Duration

source§

impl<'q> Encode<'q, Sqlite> for u32

source§

fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull

source§

impl Encode<'_, MySql> for u32

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

source§

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

source§

fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull

source§

impl<'q, T, DB: Database> Encode<'q, DB> for &Twhere T: Encode<'q, DB>,

source§

fn encode(self, buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer) -> IsNull

source§

fn encode_by_ref( &self, buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer ) -> IsNull

source§

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

source§

fn size_hint(&self) -> usize

source§

impl Encode<'_, MySql> for &str

source§

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

Implementors§

source§

impl Encode<'_, Postgres> for Oid

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<NaiveTime, FixedOffset>

source§

impl Encode<'_, Postgres> for PgTimeTz<Time, UtcOffset>

source§

impl<'q, DB> Encode<'q, DB> for JsonValuewhere for<'a> Json<&'a Self>: Encode<'q, DB>, DB: Database,

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<T> Encode<'_, MySql> for Json<T>where T: Serialize,

source§

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