@@ -12,7 +12,10 @@ fn base() -> NaiveDateTime {
1212}
1313
1414impl FromSql for NaiveDateTime {
15- fn from_sql ( _: & Type , raw : & [ u8 ] , _: & SessionInfo ) -> Result < NaiveDateTime , Box < Error + Sync + Send > > {
15+ fn from_sql ( _: & Type ,
16+ raw : & [ u8 ] ,
17+ _: & SessionInfo )
18+ -> Result < NaiveDateTime , Box < Error + Sync + Send > > {
1619 let t = try!( types:: timestamp_from_sql ( raw) ) ;
1720 Ok ( base ( ) + Duration :: microseconds ( t) )
1821 }
@@ -21,7 +24,11 @@ impl FromSql for NaiveDateTime {
2124}
2225
2326impl ToSql for NaiveDateTime {
24- fn to_sql ( & self , _: & Type , w : & mut Vec < u8 > , _: & SessionInfo ) -> Result < IsNull , Box < Error + Sync + Send > > {
27+ fn to_sql ( & self ,
28+ _: & Type ,
29+ w : & mut Vec < u8 > ,
30+ _: & SessionInfo )
31+ -> Result < IsNull , Box < Error + Sync + Send > > {
2532 let time = match ( * self - base ( ) ) . num_microseconds ( ) {
2633 Some ( time) => time,
2734 None => return Err ( "value too large to transmit" . into ( ) ) ,
@@ -35,7 +42,10 @@ impl ToSql for NaiveDateTime {
3542}
3643
3744impl FromSql for DateTime < UTC > {
38- fn from_sql ( type_ : & Type , raw : & [ u8 ] , info : & SessionInfo ) -> Result < DateTime < UTC > , Box < Error + Sync + Send > > {
45+ fn from_sql ( type_ : & Type ,
46+ raw : & [ u8 ] ,
47+ info : & SessionInfo )
48+ -> Result < DateTime < UTC > , Box < Error + Sync + Send > > {
3949 let naive = try!( NaiveDateTime :: from_sql ( type_, raw, info) ) ;
4050 Ok ( DateTime :: from_utc ( naive, UTC ) )
4151 }
@@ -44,7 +54,11 @@ impl FromSql for DateTime<UTC> {
4454}
4555
4656impl ToSql for DateTime < UTC > {
47- fn to_sql ( & self , type_ : & Type , w : & mut Vec < u8 > , info : & SessionInfo ) -> Result < IsNull , Box < Error + Sync + Send > > {
57+ fn to_sql ( & self ,
58+ type_ : & Type ,
59+ w : & mut Vec < u8 > ,
60+ info : & SessionInfo )
61+ -> Result < IsNull , Box < Error + Sync + Send > > {
4862 self . naive_utc ( ) . to_sql ( type_, w, info)
4963 }
5064
@@ -53,7 +67,10 @@ impl ToSql for DateTime<UTC> {
5367}
5468
5569impl FromSql for DateTime < Local > {
56- fn from_sql ( type_ : & Type , raw : & [ u8 ] , info : & SessionInfo ) -> Result < DateTime < Local > , Box < Error + Sync + Send > > {
70+ fn from_sql ( type_ : & Type ,
71+ raw : & [ u8 ] ,
72+ info : & SessionInfo )
73+ -> Result < DateTime < Local > , Box < Error + Sync + Send > > {
5774 let utc = try!( DateTime :: < UTC > :: from_sql ( type_, raw, info) ) ;
5875 Ok ( utc. with_timezone ( & Local ) )
5976 }
@@ -62,7 +79,11 @@ impl FromSql for DateTime<Local> {
6279}
6380
6481impl ToSql for DateTime < Local > {
65- fn to_sql ( & self , type_ : & Type , mut w : & mut Vec < u8 > , info : & SessionInfo ) -> Result < IsNull , Box < Error + Sync + Send > > {
82+ fn to_sql ( & self ,
83+ type_ : & Type ,
84+ mut w : & mut Vec < u8 > ,
85+ info : & SessionInfo )
86+ -> Result < IsNull , Box < Error + Sync + Send > > {
6687 self . with_timezone ( & UTC ) . to_sql ( type_, w, info)
6788 }
6889
@@ -71,7 +92,10 @@ impl ToSql for DateTime<Local> {
7192}
7293
7394impl FromSql for DateTime < FixedOffset > {
74- fn from_sql ( type_ : & Type , raw : & [ u8 ] , info : & SessionInfo ) -> Result < DateTime < FixedOffset > , Box < Error + Sync + Send > > {
95+ fn from_sql ( type_ : & Type ,
96+ raw : & [ u8 ] ,
97+ info : & SessionInfo )
98+ -> Result < DateTime < FixedOffset > , Box < Error + Sync + Send > > {
7599 let utc = try!( DateTime :: < UTC > :: from_sql ( type_, raw, info) ) ;
76100 Ok ( utc. with_timezone ( & FixedOffset :: east ( 0 ) ) )
77101 }
@@ -80,7 +104,11 @@ impl FromSql for DateTime<FixedOffset> {
80104}
81105
82106impl ToSql for DateTime < FixedOffset > {
83- fn to_sql ( & self , type_ : & Type , w : & mut Vec < u8 > , info : & SessionInfo ) -> Result < IsNull , Box < Error + Sync + Send > > {
107+ fn to_sql ( & self ,
108+ type_ : & Type ,
109+ w : & mut Vec < u8 > ,
110+ info : & SessionInfo )
111+ -> Result < IsNull , Box < Error + Sync + Send > > {
84112 self . with_timezone ( & UTC ) . to_sql ( type_, w, info)
85113 }
86114
@@ -89,7 +117,10 @@ impl ToSql for DateTime<FixedOffset> {
89117}
90118
91119impl FromSql for NaiveDate {
92- fn from_sql ( _: & Type , raw : & [ u8 ] , _: & SessionInfo ) -> Result < NaiveDate , Box < Error + Sync + Send > > {
120+ fn from_sql ( _: & Type ,
121+ raw : & [ u8 ] ,
122+ _: & SessionInfo )
123+ -> Result < NaiveDate , Box < Error + Sync + Send > > {
93124 let jd = try!( types:: date_from_sql ( raw) ) ;
94125 Ok ( base ( ) . date ( ) + Duration :: days ( jd as i64 ) )
95126 }
@@ -98,7 +129,11 @@ impl FromSql for NaiveDate {
98129}
99130
100131impl ToSql for NaiveDate {
101- fn to_sql ( & self , _: & Type , w : & mut Vec < u8 > , _: & SessionInfo ) -> Result < IsNull , Box < Error + Sync + Send > > {
132+ fn to_sql ( & self ,
133+ _: & Type ,
134+ w : & mut Vec < u8 > ,
135+ _: & SessionInfo )
136+ -> Result < IsNull , Box < Error + Sync + Send > > {
102137 let jd = ( * self - base ( ) . date ( ) ) . num_days ( ) ;
103138 if jd > i32:: max_value ( ) as i64 || jd < i32:: min_value ( ) as i64 {
104139 return Err ( "value too large to transmit" . into ( ) ) ;
@@ -113,7 +148,10 @@ impl ToSql for NaiveDate {
113148}
114149
115150impl FromSql for NaiveTime {
116- fn from_sql ( _: & Type , raw : & [ u8 ] , _: & SessionInfo ) -> Result < NaiveTime , Box < Error + Sync + Send > > {
151+ fn from_sql ( _: & Type ,
152+ raw : & [ u8 ] ,
153+ _: & SessionInfo )
154+ -> Result < NaiveTime , Box < Error + Sync + Send > > {
117155 let usec = try!( types:: time_from_sql ( raw) ) ;
118156 Ok ( NaiveTime :: from_hms ( 0 , 0 , 0 ) + Duration :: microseconds ( usec) )
119157 }
@@ -122,7 +160,11 @@ impl FromSql for NaiveTime {
122160}
123161
124162impl ToSql for NaiveTime {
125- fn to_sql ( & self , _: & Type , w : & mut Vec < u8 > , _: & SessionInfo ) -> Result < IsNull , Box < Error + Sync + Send > > {
163+ fn to_sql ( & self ,
164+ _: & Type ,
165+ w : & mut Vec < u8 > ,
166+ _: & SessionInfo )
167+ -> Result < IsNull , Box < Error + Sync + Send > > {
126168 let delta = * self - NaiveTime :: from_hms ( 0 , 0 , 0 ) ;
127169 let time = match delta. num_microseconds ( ) {
128170 Some ( time) => time,
0 commit comments