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

Commit9a739ed

Browse files
committed
Update postgres version
1 parentf66ed12 commit9a739ed

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

‎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"
22-
postgres ="0.10"
22+
postgres ="0.11"

‎src/lib.rs‎

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,19 @@ extern crate postgres;
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,14 +57,12 @@ 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
///
5364
/// use std::thread;
54-
/// use postgres::SslMode;
55-
/// use r2d2_postgres::PostgresConnectionManager;
65+
/// use r2d2_postgres::{SslMode, PostgresConnectionManager};
5666
///
5767
/// fn main() {
5868
/// let config = r2d2::Config::default();
@@ -84,7 +94,7 @@ impl PostgresConnectionManager {
8494
->Result<PostgresConnectionManager, postgres::error::ConnectError>{
8595
let params =match params.into_connect_params(){
8696
Ok(params) => params,
87-
Err(err) =>returnErr(postgres::error::ConnectError::BadConnectParams(err)),
97+
Err(err) =>returnErr(postgres::error::ConnectError::ConnectParams(err)),
8898
};
8999

90100
Ok(PostgresConnectionManager{
@@ -99,7 +109,12 @@ impl r2d2::ManageConnection for PostgresConnectionManager {
99109
typeError =Error;
100110

101111
fnconnect(&self) ->Result<postgres::Connection,Error>{
102-
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)
103118
}
104119

105120
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