Update docs for SSL -> TLS migration

This commit is contained in:
Steven Fackler 2016-07-01 15:26:13 -04:00
parent 2a6889fa0b
commit 935785f672
2 changed files with 13 additions and 13 deletions

View File

@ -17,7 +17,7 @@ Rust-Postgres is a pure-Rust frontend for the popular PostgreSQL database.
```rust ```rust
extern crate postgres; extern crate postgres;
use postgres::{Connection, SslMode}; use postgres::{Connection, TlsMode};
struct Person { struct Person {
id: i32, id: i32,
@ -26,7 +26,7 @@ struct Person {
} }
fn main() { fn main() {
let conn = Connection::connect("postgres://postgres@localhost", SslMode::None).unwrap(); let conn = Connection::connect("postgres://postgres@localhost", TlsMode::None).unwrap();
conn.execute("CREATE TABLE person ( conn.execute("CREATE TABLE person (
id SERIAL PRIMARY KEY, id SERIAL PRIMARY KEY,
name VARCHAR NOT NULL, name VARCHAR NOT NULL,
@ -65,7 +65,7 @@ fn main() {
Connect to a Postgres server using the standard URI format: Connect to a Postgres server using the standard URI format:
```rust ```rust
let conn = try!(Connection::connect("postgres://user:pass@host:port/database?arg1=val1&arg2=val2", let conn = try!(Connection::connect("postgres://user:pass@host:port/database?arg1=val1&arg2=val2",
SslMode::None)); TlsMode::None));
``` ```
`pass` may be omitted if not needed. `port` defaults to `5432` and `database` `pass` may be omitted if not needed. `port` defaults to `5432` and `database`
defaults to the value of `user` if not specified. The driver supports `trust`, defaults to the value of `user` if not specified. The driver supports `trust`,
@ -77,7 +77,7 @@ path to the directory containing the socket file. Since `/` is a reserved
character in URLs, the path should be URL encoded. If Postgres stored its socket character in URLs, the path should be URL encoded. If Postgres stored its socket
files in `/run/postgres`, the connection would then look like: files in `/run/postgres`, the connection would then look like:
```rust ```rust
let conn = try!(Connection::connect("postgres://postgres@%2Frun%2Fpostgres", SslMode::None)); let conn = try!(Connection::connect("postgres://postgres@%2Frun%2Fpostgres", TlsMode::None));
``` ```
Paths which contain non-UTF8 characters can be handled in a different manner; Paths which contain non-UTF8 characters can be handled in a different manner;
see the documentation for details. see the documentation for details.

View File

@ -270,13 +270,13 @@ pub struct CancelData {
/// postgres::cancel_query(url, TlsMode::None, &cancel_data).unwrap(); /// postgres::cancel_query(url, TlsMode::None, &cancel_data).unwrap();
/// ``` /// ```
pub fn cancel_query<T>(params: T, pub fn cancel_query<T>(params: T,
ssl: TlsMode, tls: TlsMode,
data: &CancelData) data: &CancelData)
-> result::Result<(), ConnectError> -> result::Result<(), ConnectError>
where T: IntoConnectParams where T: IntoConnectParams
{ {
let params = try!(params.into_connect_params().map_err(ConnectError::ConnectParams)); let params = try!(params.into_connect_params().map_err(ConnectError::ConnectParams));
let mut socket = try!(priv_io::initialize_stream(&params, ssl)); let mut socket = try!(priv_io::initialize_stream(&params, tls));
try!(socket.write_message(&Frontend::CancelRequest { try!(socket.write_message(&Frontend::CancelRequest {
code: message::CANCEL_CODE, code: message::CANCEL_CODE,
@ -302,11 +302,11 @@ fn desynchronized() -> std_io::Error {
/// Specifies the TLS support requested for a new connection. /// Specifies the TLS support requested for a new connection.
#[derive(Debug)] #[derive(Debug)]
pub enum TlsMode<'a> { pub enum TlsMode<'a> {
/// The connection will not use SSL. /// The connection will not use TLS.
None, None,
/// The connection will use SSL if the backend supports it. /// The connection will use TLS if the backend supports it.
Prefer(&'a TlsHandshake), Prefer(&'a TlsHandshake),
/// The connection must use SSL. /// The connection must use TLS.
Require(&'a TlsHandshake), Require(&'a TlsHandshake),
} }
@ -339,11 +339,11 @@ impl Drop for InnerConnection {
} }
impl InnerConnection { impl InnerConnection {
fn connect<T>(params: T, ssl: TlsMode) -> result::Result<InnerConnection, ConnectError> fn connect<T>(params: T, tls: TlsMode) -> result::Result<InnerConnection, ConnectError>
where T: IntoConnectParams where T: IntoConnectParams
{ {
let params = try!(params.into_connect_params().map_err(ConnectError::ConnectParams)); let params = try!(params.into_connect_params().map_err(ConnectError::ConnectParams));
let stream = try!(priv_io::initialize_stream(&params, ssl)); let stream = try!(priv_io::initialize_stream(&params, tls));
let ConnectParams { user, database, mut options, .. } = params; let ConnectParams { user, database, mut options, .. } = params;
@ -1027,10 +1027,10 @@ impl Connection {
/// let conn = Connection::connect(params, TlsMode::None).unwrap(); /// let conn = Connection::connect(params, TlsMode::None).unwrap();
/// # } /// # }
/// ``` /// ```
pub fn connect<T>(params: T, ssl: TlsMode) -> result::Result<Connection, ConnectError> pub fn connect<T>(params: T, tls: TlsMode) -> result::Result<Connection, ConnectError>
where T: IntoConnectParams where T: IntoConnectParams
{ {
InnerConnection::connect(params, ssl).map(|conn| Connection { conn: RefCell::new(conn) }) InnerConnection::connect(params, tls).map(|conn| Connection { conn: RefCell::new(conn) })
} }
/// Executes a statement, returning the number of rows modified. /// Executes a statement, returning the number of rows modified.