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