Skip to content

Commit 1fb208f

Browse files
committed
Merge branch 'release-v0.11.0' into release
2 parents e3db672 + 03b3384 commit 1fb208f

File tree

5 files changed

+36
-35
lines changed

5 files changed

+36
-35
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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[package]
22
name = "r2d2_postgres"
3-
version = "0.10.1"
3+
version = "0.11.0"
44
authors = ["Steven Fackler <sfackler@gmail.com>"]
55
license = "MIT"
66
description = "Postgres support for the r2d2 connection pool"
77
repository = "https://github.com/sfackler/r2d2-postgres"
8-
documentation = "https://sfackler.github.io/r2d2-postgres/doc/v0.10.1/r2d2_postgres"
8+
documentation = "https://sfackler.github.io/r2d2-postgres/doc/v0.11.0/r2d2_postgres"
99
keywords = ["postgres", "sql", "pool", "database"]
1010

1111
[lib]
@@ -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"

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ r2d2-postgres
33

44
[![Build Status](https://travis-ci.org/sfackler/r2d2-postgres.svg?branch=master)](https://travis-ci.org/sfackler/r2d2-postgres)
55

6-
[Documentation](https://sfackler.github.io/r2d2-postgres/doc/v0.10.1/r2d2_postgres)
6+
[Documentation](https://sfackler.github.io/r2d2-postgres/doc/v0.11.0/r2d2_postgres)
77

88
[rust-postgres](https://github.com/sfackler/rust-postgres) support library for the [r2d2](https://github.com/sfackler/r2d2) connection pool.
99

@@ -15,12 +15,12 @@ extern crate r2d2_postgres;
1515
extern crate postgres;
1616

1717
use std::thread;
18-
use r2d2_postgres::{SslMode, PostgresConnectionManager};
18+
use r2d2_postgres::{TlsMode, PostgresConnectionManager};
1919

2020
fn main() {
2121
let config = r2d2::Config::default();
2222
let manager = PostgresConnectionManager::new("postgres://postgres@localhost",
23-
SslMode::None).unwrap();
23+
TlsMode::None).unwrap();
2424
let pool = r2d2::Pool::new(config, manager).unwrap();
2525

2626
for i in 0..10i32 {

src/lib.rs

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
//! Postgres support for the `r2d2` connection pool.
2-
#![doc(html_root_url="https://sfackler.github.io/r2d2-postgres/doc/v0.10.1")]
2+
#![doc(html_root_url="https://sfackler.github.io/r2d2-postgres/doc/v0.11.0")]
33
#![warn(missing_docs)]
4-
extern crate r2d2;
5-
extern crate postgres;
4+
pub extern crate r2d2;
5+
pub extern crate postgres;
66

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,19 +81,20 @@ 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 {
8989
/// Creates a new `PostgresConnectionManager`.
9090
///
9191
/// See `postgres::Connection::connect` for a description of the parameter
9292
/// types.
93-
pub fn new<T: IntoConnectParams>
94-
(params: T,
95-
ssl_mode: SslMode)
96-
-> Result<PostgresConnectionManager, postgres::error::ConnectError> {
93+
pub fn new<T>(params: T,
94+
ssl_mode: TlsMode)
95+
-> Result<PostgresConnectionManager, postgres::error::ConnectError>
96+
where T: IntoConnectParams
97+
{
9798
let params = match params.into_connect_params() {
9899
Ok(params) => params,
99100
Err(err) => return Err(postgres::error::ConnectError::ConnectParams(err)),
@@ -112,9 +113,9 @@ impl r2d2::ManageConnection for PostgresConnectionManager {
112113

113114
fn connect(&self) -> Result<postgres::Connection, Error> {
114115
let mode = match self.ssl_mode {
115-
SslMode::None => postgres::SslMode::None,
116-
SslMode::Prefer(ref n) => postgres::SslMode::Prefer(&**n),
117-
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),
118119
};
119120
postgres::Connection::connect(self.params.clone(), mode).map_err(Error::Connect)
120121
}

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)