Trait postgres::types::FromSql
[−]
[src]
pub trait FromSql: Sized { fn from_sql<R: Read>(ty: &Type, raw: &mut R) -> Result<Self>; fn accepts(ty: &Type) -> bool; fn from_sql_nullable<R: Read>(ty: &Type, raw: Option<&mut R>) -> Result<Self> { ... } }
A trait for types that can be created from a Postgres value.
Required Methods
fn from_sql<R: Read>(ty: &Type, raw: &mut R) -> Result<Self>
Creates a new value of this type from a Read
er of the binary format
of the specified Postgres Type
.
The caller of this method is responsible for ensuring that this type
is compatible with the Postgres Type
.
fn accepts(ty: &Type) -> bool
Determines if a value of this type can be created from the specified
Postgres Type
.
Provided Methods
fn from_sql_nullable<R: Read>(ty: &Type, raw: Option<&mut R>) -> Result<Self>
Creates a new value of this type from a Read
of Postgres data.
If the value was NULL
, the Read
will be None
.
The caller of this method is responsible for ensuring that this type
is compatible with the Postgres Type
.
The default implementation calls FromSql::from_sql
when raw
is
Some
and returns Err(Error::WasNull)
when raw
is None
. It does
not typically need to be overridden.
Implementors
impl<T: FromSql> FromSql for Option<T>
impl FromSql for bool
impl FromSql for Vec<u8>
impl FromSql for String
impl FromSql for i8
impl FromSql for i16
impl FromSql for i32
impl FromSql for u32
impl FromSql for i64
impl FromSql for f32
impl FromSql for f64
impl FromSql for HashMap<String, Option<String>>