Skip to main content

ToSql

Trait ToSql 

Source
pub trait ToSql {
    // Required method
    fn to_sql(&self, ty: Type, out: &mut Vec<u8>) -> Result<Encoded, Error>;
}
Expand description

A Rust value that can be a statement parameter.

The server says which type each parameter has (from the SQL, as if the parameter were an untyped literal); to_sql appends the value in that type’s binary format or as text, and says which. Implement it for your own types by delegating to one of the implementations here.

Required Methods§

Source

fn to_sql(&self, ty: Type, out: &mut Vec<u8>) -> Result<Encoded, Error>

Appends the value for a parameter of type ty to out.

Return an error made with Error::conversion when the value cannot be a ty; it is reported with the parameter’s number.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl ToSql for String

Source§

fn to_sql(&self, ty: Type, out: &mut Vec<u8>) -> Result<Encoded, Error>

Source§

impl ToSql for SystemTime

Source§

fn to_sql(&self, ty: Type, out: &mut Vec<u8>) -> Result<Encoded, Error>

Source§

impl ToSql for Vec<u8>

Source§

fn to_sql(&self, ty: Type, out: &mut Vec<u8>) -> Result<Encoded, Error>

Source§

impl ToSql for [u8]

Source§

fn to_sql(&self, ty: Type, out: &mut Vec<u8>) -> Result<Encoded, Error>

Source§

impl ToSql for bool

Source§

fn to_sql(&self, ty: Type, out: &mut Vec<u8>) -> Result<Encoded, Error>

Source§

impl ToSql for f32

Source§

fn to_sql(&self, ty: Type, out: &mut Vec<u8>) -> Result<Encoded, Error>

Source§

impl ToSql for f64

Source§

fn to_sql(&self, ty: Type, out: &mut Vec<u8>) -> Result<Encoded, Error>

Source§

impl ToSql for i16

Source§

fn to_sql(&self, ty: Type, out: &mut Vec<u8>) -> Result<Encoded, Error>

Source§

impl ToSql for i32

Source§

fn to_sql(&self, ty: Type, out: &mut Vec<u8>) -> Result<Encoded, Error>

Source§

impl ToSql for i64

Source§

fn to_sql(&self, ty: Type, out: &mut Vec<u8>) -> Result<Encoded, Error>

Source§

impl ToSql for str

Source§

fn to_sql(&self, ty: Type, out: &mut Vec<u8>) -> Result<Encoded, Error>

Source§

impl<T: ToSql + ?Sized> ToSql for &T

Source§

fn to_sql(&self, ty: Type, out: &mut Vec<u8>) -> Result<Encoded, Error>

Source§

impl<T: ToSql + ?Sized> ToSql for Box<T>

Source§

fn to_sql(&self, ty: Type, out: &mut Vec<u8>) -> Result<Encoded, Error>

Source§

impl<T: ToSql> ToSql for Option<T>

Source§

fn to_sql(&self, ty: Type, out: &mut Vec<u8>) -> Result<Encoded, Error>

Source§

impl<const N: usize> ToSql for [u8; N]

Source§

fn to_sql(&self, ty: Type, out: &mut Vec<u8>) -> Result<Encoded, Error>

Implementors§