Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit91fd78a

Browse files
committed
Merge branch 'release-v0.10.0' into release
2 parents5f5091f +1afbe83 commit91fd78a

File tree

4 files changed

+29
-19
lines changed

4 files changed

+29
-19
lines changed

‎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.9.3"
3+
version ="0.10.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.9.3/r2d2_postgres"
8+
documentation ="https://sfackler.github.io/r2d2-postgres/doc/v0.10.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"
22-
postgres ="0.10"
22+
postgres ="0.11"

‎README.md‎

Lines changed: 2 additions & 4 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.9.3/r2d2_postgres)
6+
[Documentation](https://sfackler.github.io/r2d2-postgres/doc/v0.10.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

@@ -14,17 +14,15 @@ extern crate r2d2;
1414
externcrate r2d2_postgres;
1515
externcrate postgres;
1616

17-
usestd::sync::Arc;
1817
usestd::thread;
19-
usestd::default::Default;
2018
usepostgres::SslMode;
2119
user2d2_postgres::PostgresConnectionManager;
2220

2321
fnmain() {
2422
letconfig=r2d2::Config::default();
2523
letmanager=PostgresConnectionManager::new("postgres://postgres@localhost",
2624
SslMode::None).unwrap();
27-
letpool=Arc::new(r2d2::Pool::new(config,manager).unwrap());
25+
letpool=r2d2::Pool::new(config,manager).unwrap();
2826

2927
foriin0..10i32 {
3028
letpool=pool.clone();

‎src/lib.rs‎

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
//! Postgres support for the `r2d2` connection pool.
2-
#![doc(html_root_url="https://sfackler.github.io/r2d2-postgres/doc/v0.9.3")]
2+
#![doc(html_root_url="https://sfackler.github.io/r2d2-postgres/doc/v0.10.0")]
33
#![warn(missing_docs)]
44
externcrate r2d2;
55
externcrate postgres;
66

77
use std::error;
88
use std::error::Erroras _StdError;
99
use std::fmt;
10-
use postgres::{IntoConnectParams,SslMode};
10+
use postgres::{IntoConnectParams};
11+
use postgres::io::NegotiateSsl;
12+
13+
/// Like `postgres::SslMode` except that it owns its `NegotiateSsl` instance.
14+
#[derive(Debug)]
15+
pubenumSslMode{
16+
/// Like `postgres::SslMode::None`.
17+
None,
18+
/// Like `postgres::SslMode::Prefer`.
19+
Prefer(Box<NegotiateSsl +Sync +Send>),
20+
/// Like `postgres::SslMode::Require`.
21+
Require(Box<NegotiateSsl +Sync +Send>),
22+
}
1123

1224
/// A unified enum of errors returned by postgres::Connection
1325
#[derive(Debug)]
@@ -45,22 +57,18 @@ impl error::Error for Error {
4557
/// ## Example
4658
///
4759
/// ```rust,no_run
48-
/// #![allow(unstable)]
4960
/// extern crate r2d2;
5061
/// extern crate r2d2_postgres;
5162
/// extern crate postgres;
5263
///
53-
/// use std::sync::Arc;
54-
/// use std::default::Default;
5564
/// use std::thread;
56-
/// use postgres::SslMode;
57-
/// use r2d2_postgres::PostgresConnectionManager;
65+
/// use r2d2_postgres::{SslMode, PostgresConnectionManager};
5866
///
5967
/// fn main() {
6068
/// let config = r2d2::Config::default();
6169
/// let manager = PostgresConnectionManager::new("postgres://postgres@localhost",
6270
/// SslMode::None).unwrap();
63-
/// let pool =Arc::new(r2d2::Pool::new(config, manager).unwrap());
71+
/// let pool = r2d2::Pool::new(config, manager).unwrap();
6472
///
6573
/// for i in 0..10i32 {
6674
/// let pool = pool.clone();
@@ -86,7 +94,7 @@ impl PostgresConnectionManager {
8694
->Result<PostgresConnectionManager, postgres::error::ConnectError>{
8795
let params =match params.into_connect_params(){
8896
Ok(params) => params,
89-
Err(err) =>returnErr(postgres::error::ConnectError::BadConnectParams(err)),
97+
Err(err) =>returnErr(postgres::error::ConnectError::ConnectParams(err)),
9098
};
9199

92100
Ok(PostgresConnectionManager{
@@ -101,7 +109,12 @@ impl r2d2::ManageConnection for PostgresConnectionManager {
101109
typeError =Error;
102110

103111
fnconnect(&self) ->Result<postgres::Connection,Error>{
104-
postgres::Connection::connect(self.params.clone(),&self.ssl_mode).map_err(Error::Connect)
112+
let mode =matchself.ssl_mode{
113+
SslMode::None => postgres::SslMode::None,
114+
SslMode::Prefer(ref n) => postgres::SslMode::Prefer(&**n),
115+
SslMode::Require(ref n) => postgres::SslMode::Require(&**n),
116+
};
117+
postgres::Connection::connect(self.params.clone(), mode).map_err(Error::Connect)
105118
}
106119

107120
fnis_valid(&self,conn:&mut postgres::Connection) ->Result<(),Error>{

‎tests/test.rs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ use std::sync::Arc;
66
use std::sync::mpsc;
77
use std::thread;
88

9-
use postgres::SslMode;
10-
use r2d2_postgres::PostgresConnectionManager;
9+
use r2d2_postgres::{SslMode,PostgresConnectionManager};
1110

1211
#[test]
1312
fntest_basic(){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp