@@ -7,18 +7,18 @@ pub extern crate postgres;
77use std:: error;
88use std:: error:: Error as _StdError;
99use 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 ) ]
8383pub struct PostgresConnectionManager {
84- params : postgres :: ConnectParams ,
85- ssl_mode : SslMode ,
84+ params : ConnectParams ,
85+ ssl_mode : TlsMode ,
8686}
8787
8888impl 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 }
0 commit comments