Skip to content

Commit 2d5c9c5

Browse files
committed
Update for postgres changes
1 parent c20caa1 commit 2d5c9c5

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/lib.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,24 @@ use std::fmt;
1010
use std::mem;
1111
use std::rc::Rc;
1212
use postgres::{IntoConnectParams, SslMode};
13-
use postgres::error::{PostgresConnectError, PostgresError};
1413
use postgres::types::ToSql;
1514

1615
pub enum Error {
17-
ConnectError(PostgresConnectError),
18-
OtherError(PostgresError),
16+
Connect(postgres::ConnectError),
17+
Other(postgres::Error),
1918
}
2019

2120
impl fmt::Show for Error {
2221
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
2322
match *self {
24-
ConnectError(ref e) => write!(fmt, "{}", e),
25-
OtherError(ref e) => write!(fmt, "{}", e),
23+
Error::Connect(ref e) => write!(fmt, "{}", e),
24+
Error::Other(ref e) => write!(fmt, "{}", e),
2625
}
2726
}
2827
}
2928

3029
pub struct PostgresPoolManager {
31-
params: Result<postgres::ConnectParams, PostgresConnectError>,
30+
params: Result<postgres::ConnectParams, postgres::ConnectError>,
3231
ssl_mode: SslMode,
3332
}
3433

@@ -45,14 +44,14 @@ impl r2d2::PoolManager<postgres::Connection, Error> for PostgresPoolManager {
4544
fn connect(&self) -> Result<postgres::Connection, Error> {
4645
match self.params {
4746
Ok(ref p) => {
48-
postgres::Connection::connect(p.clone(), &self.ssl_mode).map_err(ConnectError)
47+
postgres::Connection::connect(p.clone(), &self.ssl_mode).map_err(Error::Connect)
4948
}
50-
Err(ref e) => Err(ConnectError(e.clone()))
49+
Err(ref e) => Err(Error::Connect(e.clone()))
5150
}
5251
}
5352

5453
fn is_valid(&self, conn: &mut postgres::Connection) -> Result<(), Error> {
55-
conn.batch_execute("").map_err(OtherError)
54+
conn.batch_execute("").map_err(Error::Other)
5655
}
5756

5857
fn has_broken(&self, conn: &mut postgres::Connection) -> bool {

0 commit comments

Comments
 (0)