Trait sqlx_core::encode::Encode

source ·
pub trait Encode<'q, DB: Database> {
    // Required method
    fn encode_by_ref(
        &self,
        buf: &mut <DB as Database>::ArgumentBuffer<'q>,
    ) -> Result<IsNull, BoxDynError>;

    // Provided methods
    fn encode(
        self,
        buf: &mut <DB as Database>::ArgumentBuffer<'q>,
    ) -> Result<IsNull, BoxDynError>
       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 Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, BoxDynError>

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, BoxDynError>
where 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<'q, DB> Encode<'q, DB> for NonZeroI8
where DB: Database, i8: Encode<'q, DB>,

source§

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

source§

fn encode( self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, BoxDynError>
where Self: Sized,

source§

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

source§

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

source§

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

source§

fn encode( self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, BoxDynError>
where Self: Sized,

source§

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

source§

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

source§

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

source§

fn encode( self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, BoxDynError>
where Self: Sized,

source§

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

source§

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

source§

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

source§

fn encode( self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, BoxDynError>
where Self: Sized,

source§

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

source§

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

source§

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

source§

fn encode( self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, BoxDynError>
where Self: Sized,

source§

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

source§

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

source§

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

source§

fn encode( self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, BoxDynError>
where Self: Sized,

source§

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

source§

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

source§

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

source§

fn encode( self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, BoxDynError>
where Self: Sized,

source§

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

source§

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

source§

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

source§

fn encode( self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, BoxDynError>
where Self: Sized,

source§

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

source§

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

source§

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

source§

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

source§

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

source§

fn size_hint(&self) -> usize

Implementors§