Skip to content

Commit e5c2eda

Browse files
committed
More enum namespacing preparation
1 parent e17d09a commit e5c2eda

6 files changed

Lines changed: 132 additions & 146 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ extern crate time;
2121

2222
use time::Timespec;
2323

24-
use postgres::{Connection, NoSsl};
24+
use postgres::{Connection, SslMode};
2525

2626
struct Person {
2727
id: i32,
@@ -31,7 +31,7 @@ struct Person {
3131
}
3232

3333
fn main() {
34-
let conn = Connection::connect("postgres://postgres@localhost", &NoSsl)
34+
let conn = Connection::connect("postgres://postgres@localhost", &SslMode::None)
3535
.unwrap();
3636

3737
conn.execute("CREATE TABLE person (
@@ -297,8 +297,8 @@ traits.
297297
### UUID type
298298

299299
[UUID](http://www.postgresql.org/docs/9.4/static/datatype-uuid.html) support is
300-
provided optionally by the `uuid` feature. It is enabled by default. To
301-
disable `UUID` support, add `default-features = false` to your Cargo manifest:
300+
provided optionally by the `uuid` feature. It is enabled by default. To disable
301+
`UUID` support, add `default-features = false` to your Cargo manifest:
302302

303303
```toml
304304
[dependencies.postgres]

src/io.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ use std::io::net::tcp;
44
use std::io::net::pipe;
55
use std::io::{Stream, IoResult};
66

7-
use {ConnectParams, SslMode, NoSsl, PreferSsl, RequireSsl, ConnectTarget};
8-
use error::{ConnectError, NoSslSupport, SslError};
7+
use {ConnectParams, SslMode, ConnectTarget, ConnectError};
98
use message;
109
use message::{SslRequest, WriteMessage};
1110

@@ -90,24 +89,24 @@ pub fn initialize_stream(params: &ConnectParams, ssl: &SslMode)
9089
let mut socket = try!(open_socket(params));
9190

9291
let (ssl_required, ctx) = match *ssl {
93-
NoSsl => return Ok(MaybeSslStream::Normal(socket)),
94-
PreferSsl(ref ctx) => (false, ctx),
95-
RequireSsl(ref ctx) => (true, ctx)
92+
SslMode::None => return Ok(MaybeSslStream::Normal(socket)),
93+
SslMode::Prefer(ref ctx) => (false, ctx),
94+
SslMode::Require(ref ctx) => (true, ctx)
9695
};
9796

9897
try!(socket.write_message(&SslRequest { code: message::SSL_CODE }));
9998
try!(socket.flush());
10099

101100
if try!(socket.read_u8()) == 'N' as u8 {
102101
if ssl_required {
103-
return Err(NoSslSupport);
102+
return Err(ConnectError::NoSslSupport);
104103
} else {
105104
return Ok(MaybeSslStream::Normal(socket));
106105
}
107106
}
108107

109108
match ssl::SslStream::new(ctx, socket) {
110109
Ok(stream) => Ok(MaybeSslStream::Ssl(stream)),
111-
Err(err) => Err(SslError(err))
110+
Err(err) => Err(ConnectError::SslError(err))
112111
}
113112
}

0 commit comments

Comments
 (0)