@@ -5,16 +5,15 @@ use self::chrono::{Duration, NaiveDate, NaiveTime, NaiveDateTime, DateTime, UTC,
5
5
FixedOffset } ;
6
6
use std:: error:: Error ;
7
7
8
- use types:: { FromSql , ToSql , IsNull , Type , SessionInfo } ;
8
+ use types:: { FromSql , ToSql , IsNull , Type } ;
9
9
10
10
fn base ( ) -> NaiveDateTime {
11
11
NaiveDate :: from_ymd ( 2000 , 1 , 1 ) . and_hms ( 0 , 0 , 0 )
12
12
}
13
13
14
14
impl FromSql for NaiveDateTime {
15
15
fn from_sql ( _: & Type ,
16
- raw : & [ u8 ] ,
17
- _: & SessionInfo )
16
+ raw : & [ u8 ] )
18
17
-> Result < NaiveDateTime , Box < Error + Sync + Send > > {
19
18
let t = try!( types:: timestamp_from_sql ( raw) ) ;
20
19
Ok ( base ( ) + Duration :: microseconds ( t) )
@@ -26,8 +25,7 @@ impl FromSql for NaiveDateTime {
26
25
impl ToSql for NaiveDateTime {
27
26
fn to_sql ( & self ,
28
27
_: & Type ,
29
- w : & mut Vec < u8 > ,
30
- _: & SessionInfo )
28
+ w : & mut Vec < u8 > )
31
29
-> Result < IsNull , Box < Error + Sync + Send > > {
32
30
let time = match self . signed_duration_since ( base ( ) ) . num_microseconds ( ) {
33
31
Some ( time) => time,
@@ -43,8 +41,7 @@ impl ToSql for NaiveDateTime {
43
41
44
42
impl FromSql for DateTime < UTC > {
45
43
fn from_sql ( type_ : & Type ,
46
- raw : & [ u8 ] ,
47
- info : & SessionInfo )
44
+ raw : & [ u8 ] )
48
45
-> Result < DateTime < UTC > , Box < Error + Sync + Send > > {
49
46
let naive = try!( NaiveDateTime :: from_sql ( type_, raw, info) ) ;
50
47
Ok ( DateTime :: from_utc ( naive, UTC ) )
@@ -56,8 +53,7 @@ impl FromSql for DateTime<UTC> {
56
53
impl ToSql for DateTime < UTC > {
57
54
fn to_sql ( & self ,
58
55
type_ : & Type ,
59
- w : & mut Vec < u8 > ,
60
- info : & SessionInfo )
56
+ w : & mut Vec < u8 > )
61
57
-> Result < IsNull , Box < Error + Sync + Send > > {
62
58
self . naive_utc ( ) . to_sql ( type_, w, info)
63
59
}
@@ -68,8 +64,7 @@ impl ToSql for DateTime<UTC> {
68
64
69
65
impl FromSql for DateTime < Local > {
70
66
fn from_sql ( type_ : & Type ,
71
- raw : & [ u8 ] ,
72
- info : & SessionInfo )
67
+ raw : & [ u8 ] )
73
68
-> Result < DateTime < Local > , Box < Error + Sync + Send > > {
74
69
let utc = try!( DateTime :: < UTC > :: from_sql ( type_, raw, info) ) ;
75
70
Ok ( utc. with_timezone ( & Local ) )
@@ -81,8 +76,7 @@ impl FromSql for DateTime<Local> {
81
76
impl ToSql for DateTime < Local > {
82
77
fn to_sql ( & self ,
83
78
type_ : & Type ,
84
- mut w : & mut Vec < u8 > ,
85
- info : & SessionInfo )
79
+ mut w : & mut Vec < u8 > )
86
80
-> Result < IsNull , Box < Error + Sync + Send > > {
87
81
self . with_timezone ( & UTC ) . to_sql ( type_, w, info)
88
82
}
@@ -93,8 +87,7 @@ impl ToSql for DateTime<Local> {
93
87
94
88
impl FromSql for DateTime < FixedOffset > {
95
89
fn from_sql ( type_ : & Type ,
96
- raw : & [ u8 ] ,
97
- info : & SessionInfo )
90
+ raw : & [ u8 ] )
98
91
-> Result < DateTime < FixedOffset > , Box < Error + Sync + Send > > {
99
92
let utc = try!( DateTime :: < UTC > :: from_sql ( type_, raw, info) ) ;
100
93
Ok ( utc. with_timezone ( & FixedOffset :: east ( 0 ) ) )
@@ -106,8 +99,7 @@ impl FromSql for DateTime<FixedOffset> {
106
99
impl ToSql for DateTime < FixedOffset > {
107
100
fn to_sql ( & self ,
108
101
type_ : & Type ,
109
- w : & mut Vec < u8 > ,
110
- info : & SessionInfo )
102
+ w : & mut Vec < u8 > )
111
103
-> Result < IsNull , Box < Error + Sync + Send > > {
112
104
self . with_timezone ( & UTC ) . to_sql ( type_, w, info)
113
105
}
@@ -118,8 +110,7 @@ impl ToSql for DateTime<FixedOffset> {
118
110
119
111
impl FromSql for NaiveDate {
120
112
fn from_sql ( _: & Type ,
121
- raw : & [ u8 ] ,
122
- _: & SessionInfo )
113
+ raw : & [ u8 ] )
123
114
-> Result < NaiveDate , Box < Error + Sync + Send > > {
124
115
let jd = try!( types:: date_from_sql ( raw) ) ;
125
116
Ok ( base ( ) . date ( ) + Duration :: days ( jd as i64 ) )
@@ -131,8 +122,7 @@ impl FromSql for NaiveDate {
131
122
impl ToSql for NaiveDate {
132
123
fn to_sql ( & self ,
133
124
_: & Type ,
134
- w : & mut Vec < u8 > ,
135
- _: & SessionInfo )
125
+ w : & mut Vec < u8 > )
136
126
-> Result < IsNull , Box < Error + Sync + Send > > {
137
127
let jd = self . signed_duration_since ( base ( ) . date ( ) ) . num_days ( ) ;
138
128
if jd > i32:: max_value ( ) as i64 || jd < i32:: min_value ( ) as i64 {
@@ -149,8 +139,7 @@ impl ToSql for NaiveDate {
149
139
150
140
impl FromSql for NaiveTime {
151
141
fn from_sql ( _: & Type ,
152
- raw : & [ u8 ] ,
153
- _: & SessionInfo )
142
+ raw : & [ u8 ] )
154
143
-> Result < NaiveTime , Box < Error + Sync + Send > > {
155
144
let usec = try!( types:: time_from_sql ( raw) ) ;
156
145
Ok ( NaiveTime :: from_hms ( 0 , 0 , 0 ) + Duration :: microseconds ( usec) )
@@ -162,8 +151,7 @@ impl FromSql for NaiveTime {
162
151
impl ToSql for NaiveTime {
163
152
fn to_sql ( & self ,
164
153
_: & Type ,
165
- w : & mut Vec < u8 > ,
166
- _: & SessionInfo )
154
+ w : & mut Vec < u8 > )
167
155
-> Result < IsNull , Box < Error + Sync + Send > > {
168
156
let delta = self . signed_duration_since ( NaiveTime :: from_hms ( 0 , 0 , 0 ) ) ;
169
157
let time = match delta. num_microseconds ( ) {
0 commit comments