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) -> IsNull
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<'a> Encode<'a, Any> for &'a str

source§

fn encode(self, buf: &mut <Any as HasArguments<'a>>::ArgumentBuffer) -> IsNull
where Self: Sized,

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

Implementors§

source§

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