diff --git a/src/types/json.rs b/src/types/json.rs index e269d8d1..72d1fbe8 100644 --- a/src/types/json.rs +++ b/src/types/json.rs @@ -1,7 +1,7 @@ use serialize::json; use {Result, Error}; -use types::{RawFromSql, RawToSql, Type}; +use types::{FromSql, RawToSql, Type}; impl FromSql for json::Json { fn from_sql(ty: &Type, raw: &mut R) -> Result { diff --git a/src/types/time.rs b/src/types/time.rs index 46855f3f..d9e09cda 100644 --- a/src/types/time.rs +++ b/src/types/time.rs @@ -1,6 +1,6 @@ use time::Timespec; use Result; -use types::{RawFromSql, Type, RawToSql}; +use types::{Type, FromSql, RawToSql}; const USEC_PER_SEC: i64 = 1_000_000; const NSEC_PER_USEC: i64 = 1_000; @@ -8,8 +8,8 @@ const NSEC_PER_USEC: i64 = 1_000; // Number of seconds from 1970-01-01 to 2000-01-01 const TIME_SEC_CONVERSION: i64 = 946684800; -impl RawFromSql for Timespec { - fn raw_from_sql(_: &Type, raw: &mut R) -> Result { +impl FromSql for Timespec { + fn from_sql(_: &Type, raw: &mut R) -> Result { let t = try!(raw.read_be_i64()); let mut sec = t / USEC_PER_SEC + TIME_SEC_CONVERSION; let mut usec = t % USEC_PER_SEC; @@ -21,9 +21,9 @@ impl RawFromSql for Timespec { Ok(Timespec::new(sec, (usec * NSEC_PER_USEC) as i32)) } -} -from_raw_from_impl!(Type::Timestamp, Type::TimestampTZ; Timespec); + accepts!(Type::Timestamp, Type::TimestampTZ); +} impl RawToSql for Timespec { fn raw_to_sql(&self, _: &Type, w: &mut W) -> Result<()> { diff --git a/src/types/uuid.rs b/src/types/uuid.rs index 16d9fbd3..3eb80f92 100644 --- a/src/types/uuid.rs +++ b/src/types/uuid.rs @@ -1,20 +1,20 @@ extern crate uuid; use self::uuid::Uuid; -use types::{RawFromSql, ToSql, RawToSql, Type}; +use types::{FromSql, ToSql, RawToSql, Type}; use Error; use Result; -impl RawFromSql for Uuid { - fn raw_from_sql(_: &Type, raw: &mut R) -> Result { +impl FromSql for Uuid { + fn from_sql(_: &Type, raw: &mut R) -> Result { match Uuid::from_bytes(&*try!(raw.read_to_end())) { Some(u) => Ok(u), None => Err(Error::BadResponse), } } -} -from_raw_from_impl!(Type::Uuid; Uuid); + accepts!(Type::Uuid); +} impl RawToSql for Uuid { fn raw_to_sql(&self, _: &Type, w: &mut W) -> Result<()> {