Trait postgres::types::ToSql
[−]
[src]
pub trait ToSql: Debug { fn to_sql<W: ?Sized>(&self, ty: &Type, out: &mut W) -> Result<IsNull> where Self: Sized, W: Write; fn accepts(ty: &Type) -> bool where Self: Sized; fn to_sql_checked(&self, ty: &Type, out: &mut Write) -> Result<IsNull>; }
A trait for types that can be converted into Postgres values.
Required Methods
fn to_sql<W: ?Sized>(&self, ty: &Type, out: &mut W) -> Result<IsNull> where Self: Sized, W: Write
Converts the value of self
into the binary format of the specified
Postgres Type
, writing it to out
.
The caller of this method is responsible for ensuring that this type
is compatible with the Postgres Type
.
The return value indicates if this value should be represented as
NULL
. If this is the case, implementations must not write
anything to out
.
fn accepts(ty: &Type) -> bool where Self: Sized
Determines if a value of this type can be converted to the specified
Postgres Type
.
fn to_sql_checked(&self, ty: &Type, out: &mut Write) -> Result<IsNull>
An adaptor method used internally by Rust-Postgres.
All implementations of this method should be generated by the
to_sql_checked!()
macro.
Implementors
impl<'a, T: 'a + ToSql> ToSql for Slice<'a, T>
impl<T: ToSql> ToSql for Option<T>
impl ToSql for bool
impl<'a> ToSql for &'a [u8]
impl ToSql for Vec<u8>
impl<'a> ToSql for &'a str
impl ToSql for String
impl ToSql for i8
impl ToSql for i16
impl ToSql for i32
impl ToSql for u32
impl ToSql for i64
impl ToSql for f32
impl ToSql for f64
impl ToSql for HashMap<String, Option<String>>