11extern crate chrono;
22
3- use postgres_protocol:: types;
43use self :: chrono:: { DateTime , Duration , FixedOffset , Local , NaiveDate , NaiveDateTime , NaiveTime ,
54 Utc } ;
5+ use postgres_protocol:: types;
66use std:: error:: Error ;
77
88use types:: { FromSql , IsNull , ToSql , Type , DATE , TIME , TIMESTAMP , TIMESTAMPTZ } ;
@@ -11,7 +11,7 @@ fn base() -> NaiveDateTime {
1111 NaiveDate :: from_ymd ( 2000 , 1 , 1 ) . and_hms ( 0 , 0 , 0 )
1212}
1313
14- impl FromSql for NaiveDateTime {
14+ impl < ' a > FromSql < ' a > for NaiveDateTime {
1515 fn from_sql ( _: & Type , raw : & [ u8 ] ) -> Result < NaiveDateTime , Box < Error + Sync + Send > > {
1616 let t = types:: timestamp_from_sql ( raw) ?;
1717 Ok ( base ( ) + Duration :: microseconds ( t) )
@@ -34,7 +34,7 @@ impl ToSql for NaiveDateTime {
3434 to_sql_checked ! ( ) ;
3535}
3636
37- impl FromSql for DateTime < Utc > {
37+ impl < ' a > FromSql < ' a > for DateTime < Utc > {
3838 fn from_sql ( type_ : & Type , raw : & [ u8 ] ) -> Result < DateTime < Utc > , Box < Error + Sync + Send > > {
3939 let naive = NaiveDateTime :: from_sql ( type_, raw) ?;
4040 Ok ( DateTime :: from_utc ( naive, Utc ) )
@@ -52,7 +52,7 @@ impl ToSql for DateTime<Utc> {
5252 to_sql_checked ! ( ) ;
5353}
5454
55- impl FromSql for DateTime < Local > {
55+ impl < ' a > FromSql < ' a > for DateTime < Local > {
5656 fn from_sql ( type_ : & Type , raw : & [ u8 ] ) -> Result < DateTime < Local > , Box < Error + Sync + Send > > {
5757 let utc = DateTime :: < Utc > :: from_sql ( type_, raw) ?;
5858 Ok ( utc. with_timezone ( & Local ) )
@@ -70,7 +70,7 @@ impl ToSql for DateTime<Local> {
7070 to_sql_checked ! ( ) ;
7171}
7272
73- impl FromSql for DateTime < FixedOffset > {
73+ impl < ' a > FromSql < ' a > for DateTime < FixedOffset > {
7474 fn from_sql (
7575 type_ : & Type ,
7676 raw : & [ u8 ] ,
@@ -91,7 +91,7 @@ impl ToSql for DateTime<FixedOffset> {
9191 to_sql_checked ! ( ) ;
9292}
9393
94- impl FromSql for NaiveDate {
94+ impl < ' a > FromSql < ' a > for NaiveDate {
9595 fn from_sql ( _: & Type , raw : & [ u8 ] ) -> Result < NaiveDate , Box < Error + Sync + Send > > {
9696 let jd = types:: date_from_sql ( raw) ?;
9797 Ok ( base ( ) . date ( ) + Duration :: days ( jd as i64 ) )
@@ -115,7 +115,7 @@ impl ToSql for NaiveDate {
115115 to_sql_checked ! ( ) ;
116116}
117117
118- impl FromSql for NaiveTime {
118+ impl < ' a > FromSql < ' a > for NaiveTime {
119119 fn from_sql ( _: & Type , raw : & [ u8 ] ) -> Result < NaiveTime , Box < Error + Sync + Send > > {
120120 let usec = types:: time_from_sql ( raw) ?;
121121 Ok ( NaiveTime :: from_hms ( 0 , 0 , 0 ) + Duration :: microseconds ( usec) )
0 commit comments