Skip to content

Commit a8ed34b

Browse files
committed
Remove SessionInfo
This was never actually used, and is incompatible with tokio-postgres's API.
1 parent 79644f9 commit a8ed34b

File tree

18 files changed

+143
-236
lines changed

18 files changed

+143
-236
lines changed

postgres-shared/src/types/bit_vec.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ use postgres_protocol::types;
44
use self::bit_vec::BitVec;
55
use std::error::Error;
66

7-
use types::{FromSql, ToSql, IsNull, Type, SessionInfo};
7+
use types::{FromSql, ToSql, IsNull, Type};
88

99
impl FromSql for BitVec {
10-
fn from_sql(_: &Type, raw: &[u8], _: &SessionInfo) -> Result<BitVec, Box<Error + Sync + Send>> {
10+
fn from_sql(_: &Type, raw: &[u8]) -> Result<BitVec, Box<Error + Sync + Send>> {
1111
let varbit = try!(types::varbit_from_sql(raw));
1212
let mut bitvec = BitVec::from_bytes(varbit.bytes());
1313
while bitvec.len() > varbit.len() {
@@ -23,8 +23,7 @@ impl FromSql for BitVec {
2323
impl ToSql for BitVec {
2424
fn to_sql(&self,
2525
_: &Type,
26-
mut out: &mut Vec<u8>,
27-
_: &SessionInfo)
26+
mut out: &mut Vec<u8>)
2827
-> Result<IsNull, Box<Error + Sync + Send>> {
2928
try!(types::varbit_to_sql(self.len(), self.to_bytes().into_iter(), out));
3029
Ok(IsNull::No)

postgres-shared/src/types/chrono.rs

+13-25
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@ use self::chrono::{Duration, NaiveDate, NaiveTime, NaiveDateTime, DateTime, UTC,
55
FixedOffset};
66
use std::error::Error;
77

8-
use types::{FromSql, ToSql, IsNull, Type, SessionInfo};
8+
use types::{FromSql, ToSql, IsNull, Type};
99

1010
fn base() -> NaiveDateTime {
1111
NaiveDate::from_ymd(2000, 1, 1).and_hms(0, 0, 0)
1212
}
1313

1414
impl FromSql for NaiveDateTime {
1515
fn from_sql(_: &Type,
16-
raw: &[u8],
17-
_: &SessionInfo)
16+
raw: &[u8])
1817
-> Result<NaiveDateTime, Box<Error + Sync + Send>> {
1918
let t = try!(types::timestamp_from_sql(raw));
2019
Ok(base() + Duration::microseconds(t))
@@ -26,8 +25,7 @@ impl FromSql for NaiveDateTime {
2625
impl ToSql for NaiveDateTime {
2726
fn to_sql(&self,
2827
_: &Type,
29-
w: &mut Vec<u8>,
30-
_: &SessionInfo)
28+
w: &mut Vec<u8>)
3129
-> Result<IsNull, Box<Error + Sync + Send>> {
3230
let time = match self.signed_duration_since(base()).num_microseconds() {
3331
Some(time) => time,
@@ -43,8 +41,7 @@ impl ToSql for NaiveDateTime {
4341

4442
impl FromSql for DateTime<UTC> {
4543
fn from_sql(type_: &Type,
46-
raw: &[u8],
47-
info: &SessionInfo)
44+
raw: &[u8])
4845
-> Result<DateTime<UTC>, Box<Error + Sync + Send>> {
4946
let naive = try!(NaiveDateTime::from_sql(type_, raw, info));
5047
Ok(DateTime::from_utc(naive, UTC))
@@ -56,8 +53,7 @@ impl FromSql for DateTime<UTC> {
5653
impl ToSql for DateTime<UTC> {
5754
fn to_sql(&self,
5855
type_: &Type,
59-
w: &mut Vec<u8>,
60-
info: &SessionInfo)
56+
w: &mut Vec<u8>)
6157
-> Result<IsNull, Box<Error + Sync + Send>> {
6258
self.naive_utc().to_sql(type_, w, info)
6359
}
@@ -68,8 +64,7 @@ impl ToSql for DateTime<UTC> {
6864

6965
impl FromSql for DateTime<Local> {
7066
fn from_sql(type_: &Type,
71-
raw: &[u8],
72-
info: &SessionInfo)
67+
raw: &[u8])
7368
-> Result<DateTime<Local>, Box<Error + Sync + Send>> {
7469
let utc = try!(DateTime::<UTC>::from_sql(type_, raw, info));
7570
Ok(utc.with_timezone(&Local))
@@ -81,8 +76,7 @@ impl FromSql for DateTime<Local> {
8176
impl ToSql for DateTime<Local> {
8277
fn to_sql(&self,
8378
type_: &Type,
84-
mut w: &mut Vec<u8>,
85-
info: &SessionInfo)
79+
mut w: &mut Vec<u8>)
8680
-> Result<IsNull, Box<Error + Sync + Send>> {
8781
self.with_timezone(&UTC).to_sql(type_, w, info)
8882
}
@@ -93,8 +87,7 @@ impl ToSql for DateTime<Local> {
9387

9488
impl FromSql for DateTime<FixedOffset> {
9589
fn from_sql(type_: &Type,
96-
raw: &[u8],
97-
info: &SessionInfo)
90+
raw: &[u8])
9891
-> Result<DateTime<FixedOffset>, Box<Error + Sync + Send>> {
9992
let utc = try!(DateTime::<UTC>::from_sql(type_, raw, info));
10093
Ok(utc.with_timezone(&FixedOffset::east(0)))
@@ -106,8 +99,7 @@ impl FromSql for DateTime<FixedOffset> {
10699
impl ToSql for DateTime<FixedOffset> {
107100
fn to_sql(&self,
108101
type_: &Type,
109-
w: &mut Vec<u8>,
110-
info: &SessionInfo)
102+
w: &mut Vec<u8>)
111103
-> Result<IsNull, Box<Error + Sync + Send>> {
112104
self.with_timezone(&UTC).to_sql(type_, w, info)
113105
}
@@ -118,8 +110,7 @@ impl ToSql for DateTime<FixedOffset> {
118110

119111
impl FromSql for NaiveDate {
120112
fn from_sql(_: &Type,
121-
raw: &[u8],
122-
_: &SessionInfo)
113+
raw: &[u8])
123114
-> Result<NaiveDate, Box<Error + Sync + Send>> {
124115
let jd = try!(types::date_from_sql(raw));
125116
Ok(base().date() + Duration::days(jd as i64))
@@ -131,8 +122,7 @@ impl FromSql for NaiveDate {
131122
impl ToSql for NaiveDate {
132123
fn to_sql(&self,
133124
_: &Type,
134-
w: &mut Vec<u8>,
135-
_: &SessionInfo)
125+
w: &mut Vec<u8>)
136126
-> Result<IsNull, Box<Error + Sync + Send>> {
137127
let jd = self.signed_duration_since(base().date()).num_days();
138128
if jd > i32::max_value() as i64 || jd < i32::min_value() as i64 {
@@ -149,8 +139,7 @@ impl ToSql for NaiveDate {
149139

150140
impl FromSql for NaiveTime {
151141
fn from_sql(_: &Type,
152-
raw: &[u8],
153-
_: &SessionInfo)
142+
raw: &[u8])
154143
-> Result<NaiveTime, Box<Error + Sync + Send>> {
155144
let usec = try!(types::time_from_sql(raw));
156145
Ok(NaiveTime::from_hms(0, 0, 0) + Duration::microseconds(usec))
@@ -162,8 +151,7 @@ impl FromSql for NaiveTime {
162151
impl ToSql for NaiveTime {
163152
fn to_sql(&self,
164153
_: &Type,
165-
w: &mut Vec<u8>,
166-
_: &SessionInfo)
154+
w: &mut Vec<u8>)
167155
-> Result<IsNull, Box<Error + Sync + Send>> {
168156
let delta = self.signed_duration_since(NaiveTime::from_hms(0, 0, 0));
169157
let time = match delta.num_microseconds() {

postgres-shared/src/types/eui48.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ use self::eui48::MacAddress;
44
use std::error::Error;
55
use postgres_protocol::types;
66

7-
use types::{FromSql, ToSql, Type, IsNull, SessionInfo};
7+
use types::{FromSql, ToSql, Type, IsNull};
88

99
impl FromSql for MacAddress {
1010
fn from_sql(_: &Type,
11-
raw: &[u8],
12-
_: &SessionInfo)
11+
raw: &[u8])
1312
-> Result<MacAddress, Box<Error + Sync + Send>> {
1413
let bytes = try!(types::macaddr_from_sql(raw));
1514
Ok(MacAddress::new(bytes))
@@ -21,8 +20,7 @@ impl FromSql for MacAddress {
2120
impl ToSql for MacAddress {
2221
fn to_sql(&self,
2322
_: &Type,
24-
w: &mut Vec<u8>,
25-
_: &SessionInfo)
23+
w: &mut Vec<u8>)
2624
-> Result<IsNull, Box<Error + Sync + Send>> {
2725
let mut bytes = [0; 6];
2826
bytes.copy_from_slice(self.as_bytes());

0 commit comments

Comments
 (0)