Skip to content

Commit 64731b2

Browse files
committed
Update to postgres 0.12
1 parent 02a830a commit 64731b2

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
language: rust
22
rust:
33
- nightly
4-
- beta
5-
- 1.8.0
4+
- 1.10.0
65
addons:
7-
postgresql: 9.3
6+
postgresql: 9.4
7+
cache: cargo
88
script:
99
- cargo test

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ path = "tests/test.rs"
1919

2020
[dependencies]
2121
r2d2 = ">= 0.6, < 0.8"
22-
postgres = "0.11"
22+
postgres = "0.12"

src/lib.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ pub extern crate postgres;
77
use std::error;
88
use std::error::Error as _StdError;
99
use std::fmt;
10-
use postgres::IntoConnectParams;
11-
use postgres::io::NegotiateSsl;
10+
use postgres::params::{ConnectParams, IntoConnectParams};
11+
use postgres::tls::TlsHandshake;
1212

13-
/// Like `postgres::SslMode` except that it owns its `NegotiateSsl` instance.
13+
/// Like `postgres::TlsMode` except that it owns its `TlsHandshake` instance.
1414
#[derive(Debug)]
15-
pub enum SslMode {
16-
/// Like `postgres::SslMode::None`.
15+
pub enum TlsMode {
16+
/// Like `postgres::TlsMode::None`.
1717
None,
18-
/// Like `postgres::SslMode::Prefer`.
19-
Prefer(Box<NegotiateSsl + Sync + Send>),
20-
/// Like `postgres::SslMode::Require`.
21-
Require(Box<NegotiateSsl + Sync + Send>),
18+
/// Like `postgres::TlsMode::Prefer`.
19+
Prefer(Box<TlsHandshake + Sync + Send>),
20+
/// Like `postgres::TlsMode::Require`.
21+
Require(Box<TlsHandshake + Sync + Send>),
2222
}
2323

2424
/// A unified enum of errors returned by postgres::Connection
@@ -62,12 +62,12 @@ impl error::Error for Error {
6262
/// extern crate postgres;
6363
///
6464
/// use std::thread;
65-
/// use r2d2_postgres::{SslMode, PostgresConnectionManager};
65+
/// use r2d2_postgres::{TlsMode, PostgresConnectionManager};
6666
///
6767
/// fn main() {
6868
/// let config = r2d2::Config::default();
6969
/// let manager = PostgresConnectionManager::new("postgres://postgres@localhost",
70-
/// SslMode::None).unwrap();
70+
/// TlsMode::None).unwrap();
7171
/// let pool = r2d2::Pool::new(config, manager).unwrap();
7272
///
7373
/// for i in 0..10i32 {
@@ -81,8 +81,8 @@ impl error::Error for Error {
8181
/// ```
8282
#[derive(Debug)]
8383
pub struct PostgresConnectionManager {
84-
params: postgres::ConnectParams,
85-
ssl_mode: SslMode,
84+
params: ConnectParams,
85+
ssl_mode: TlsMode,
8686
}
8787

8888
impl PostgresConnectionManager {
@@ -91,7 +91,7 @@ impl PostgresConnectionManager {
9191
/// See `postgres::Connection::connect` for a description of the parameter
9292
/// types.
9393
pub fn new<T>(params: T,
94-
ssl_mode: SslMode)
94+
ssl_mode: TlsMode)
9595
-> Result<PostgresConnectionManager, postgres::error::ConnectError>
9696
where T: IntoConnectParams
9797
{
@@ -113,9 +113,9 @@ impl r2d2::ManageConnection for PostgresConnectionManager {
113113

114114
fn connect(&self) -> Result<postgres::Connection, Error> {
115115
let mode = match self.ssl_mode {
116-
SslMode::None => postgres::SslMode::None,
117-
SslMode::Prefer(ref n) => postgres::SslMode::Prefer(&**n),
118-
SslMode::Require(ref n) => postgres::SslMode::Require(&**n),
116+
TlsMode::None => postgres::TlsMode::None,
117+
TlsMode::Prefer(ref n) => postgres::TlsMode::Prefer(&**n),
118+
TlsMode::Require(ref n) => postgres::TlsMode::Require(&**n),
119119
};
120120
postgres::Connection::connect(self.params.clone(), mode).map_err(Error::Connect)
121121
}

tests/test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ use std::sync::Arc;
66
use std::sync::mpsc;
77
use std::thread;
88

9-
use r2d2_postgres::{SslMode, PostgresConnectionManager};
9+
use r2d2_postgres::{TlsMode, PostgresConnectionManager};
1010

1111
#[test]
1212
fn test_basic() {
13-
let manager = PostgresConnectionManager::new("postgres://postgres@localhost", SslMode::None).unwrap();
13+
let manager = PostgresConnectionManager::new("postgres://postgres@localhost", TlsMode::None).unwrap();
1414
let config = r2d2::Config::builder().pool_size(2).build();
1515
let pool = Arc::new(r2d2::Pool::new(config, manager).unwrap());
1616

@@ -41,7 +41,7 @@ fn test_basic() {
4141

4242
#[test]
4343
fn test_is_valid() {
44-
let manager = PostgresConnectionManager::new("postgres://postgres@localhost", SslMode::None).unwrap();
44+
let manager = PostgresConnectionManager::new("postgres://postgres@localhost", TlsMode::None).unwrap();
4545
let config = r2d2::Config::builder().pool_size(1).test_on_check_out(true).build();
4646
let pool = r2d2::Pool::new(config, manager).unwrap();
4747

0 commit comments

Comments
 (0)