Skip to content

Commit f2cf6be

Browse files
committed
Rename all features
You can't add dependencies to implicit features, so move them all just in case.
1 parent c3aed44 commit f2cf6be

11 files changed

Lines changed: 105 additions & 69 deletions

File tree

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ before_script:
1111
- "./.travis/setup.sh"
1212
script:
1313
- cargo test
14-
- cargo test --features "uuid rustc-serialize time unix_socket serde_json chrono with-openssl bit-vec eui48"
14+
- cargo test --features "with-uuid with-rustc-serialize with-time with-unix_socket with-serde_json with-chrono with-openssl with-bit-vec with-eui48"
1515
- (test $TRAVIS_RUST_VERSION != "nightly" || cargo test --features nightly)

Cargo.toml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,34 @@ path = "tests/test.rs"
2222

2323
[features]
2424
nightly = []
25+
with-bit-vec = ["bit-vec"]
26+
with-chrono = ["chrono"]
27+
with-eui48 = ["eui48"]
2528
with-openssl = ["openssl", "openssl-verify"]
29+
with-rustc-serialize = ["rustc-serialize"]
30+
with-security-framework = ["security-framework"]
31+
with-serde_json = ["serde_json"]
32+
with-time = ["time"]
33+
with-unix_socket = ["unix_socket"]
34+
with-uuid = ["uuid"]
2635

2736
[dependencies]
2837
bufstream = "0.1"
2938
byteorder = "0.5"
39+
hex = "0.2"
3040
log = "0.3"
3141
phf = "=0.7.15"
32-
hex = "0.2"
33-
rustc-serialize = { version = "0.3", optional = true }
42+
bit-vec = { version = "0.4", optional = true }
3443
chrono = { version = "0.2.14", optional = true }
44+
eui48 = { version = "0.1", optional = true }
3545
openssl = { version = ">= 0.6.4, < 0.8", optional = true }
3646
openssl-verify = { version = "0.1", optional = true }
47+
rustc-serialize = { version = "0.3", optional = true }
48+
security-framework = { version = "0.1.2", optional = true }
3749
serde_json = { version = ">= 0.6, < 0.9", optional = true }
3850
time = { version = "0.1.14", optional = true }
3951
unix_socket = { version = "0.5", optional = true }
4052
uuid = { version = ">= 0.1, < 0.4", optional = true }
41-
security-framework = { version = "0.1.2", optional = true }
42-
bit-vec = { version = "0.4", optional = true }
43-
eui48 = { version = "0.1", optional = true }
4453

4554
[dev-dependencies]
4655
url = "1.0"

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ let conn = try!(Connection::connect("postgres://user:pass@host:port/database?arg
7171
defaults to the value of `user` if not specified. The driver supports `trust`,
7272
`password`, and `md5` authentication.
7373

74-
Unix domain sockets can be used as well by activating the `unix_socket` or
74+
Unix domain sockets can be used as well by activating the `with-unix_socket` or
7575
`nightly` features. The `host` portion of the URI should be set to the absolute
7676
path to the directory containing the socket file. Since `/` is a reserved
7777
character in URLs, the path should be URL encoded. If Postgres stored its socket
@@ -288,39 +288,39 @@ crate.
288288
### Unix socket connections
289289

290290
Support for connections through Unix domain sockets is provided optionally by
291-
either the `unix_socket` or `nightly` features. It is only available on "unixy"
292-
platforms such as OSX, BSD and Linux.
291+
either the `with-unix_socket` or `nightly` features. It is only available on
292+
"unixy" platforms such as OSX, BSD and Linux.
293293

294294
### UUID type
295295

296296
[UUID](http://www.postgresql.org/docs/9.4/static/datatype-uuid.html) support is
297-
provided optionally by the `uuid` feature, which adds `ToSql` and `FromSql`
297+
provided optionally by the `with-uuid` feature, which adds `ToSql` and `FromSql`
298298
implementations for `uuid`'s `Uuid` type.
299299

300300
### JSON/JSONB types
301301

302302
[JSON and JSONB](http://www.postgresql.org/docs/9.4/static/datatype-json.html)
303-
support is provided optionally by the `rustc-serialize` feature, which adds
303+
support is provided optionally by the `with-rustc-serialize` feature, which adds
304304
`ToSql` and `FromSql` implementations for `rustc-serialize`'s `Json` type, and
305-
the `serde_json` feature, which adds implementations for `serde_json`'s `Value`
306-
type.
305+
the `with-serde_json` feature, which adds implementations for `serde_json`'s
306+
`Value` type.
307307

308308
### TIMESTAMP/TIMESTAMPTZ/DATE/TIME types
309309

310310
[Date and Time](http://www.postgresql.org/docs/9.1/static/datatype-datetime.html)
311-
support is provided optionally by the `time` feature, which adds `ToSql` and
312-
`FromSql` implementations for `time`'s `Timespec` type, or the `chrono`
311+
support is provided optionally by the `with-time` feature, which adds `ToSql`
312+
and `FromSql` implementations for `time`'s `Timespec` type, or the `with-chrono`
313313
feature, which adds `ToSql` and `FromSql` implementations for `chrono`'s
314314
`DateTime`, `NaiveDateTime`, `NaiveDate` and `NaiveTime` types.
315315

316316
### BIT/VARBIT types
317317

318318
[BIT and VARBIT](http://www.postgresql.org/docs/9.4/static/datatype-bit.html)
319-
support is provided optionally by the `bit-vec` feature, which adds `ToSql` and
320-
`FromSql` implementations for `bit-vec`'s `BitVec` type.
319+
support is provided optionally by the `with-bit-vec` feature, which adds `ToSql`
320+
and `FromSql` implementations for `bit-vec`'s `BitVec` type.
321321

322322
### MACADDR type
323323

324324
[MACADDR](http://www.postgresql.org/docs/9.4/static/datatype-net-types.html#DATATYPE-MACADDR)
325-
support is provided optionally by the `eui48` feature, which adds `ToSql` and
326-
`FromSql` implementations for `eui48`'s `MacAddress` type.
325+
support is provided optionally by the `with-eui48` feature, which adds `ToSql`
326+
and `FromSql` implementations for `eui48`'s `MacAddress` type.

src/feature_check.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#[cfg(all(feature = "bit-vec", not(feature = "with-bit-vec")))]
2+
const _CHECK: BitVecFeatureRenamedSeeDocs = ();
3+
4+
#[cfg(all(feature = "chrono", not(feature = "with-chrono")))]
5+
const _CHECK: ChronoFeatureRenamedSeeDocs = ();
6+
7+
#[cfg(all(feature = "eui48", not(feature = "with-eui48")))]
8+
const _CHECK: Eui48FeatureRenamedSeeDocs = ();
9+
10+
#[cfg(all(feature = "openssl", not(feature = "with-openssl")))]
11+
const _CHECK: OpensslFeatureRenamedSeeDocs = ();
12+
13+
#[cfg(all(feature = "rustc-serialize", not(feature = "with-rustc-serialize")))]
14+
const _CHECK: RustcSerializeFeatureRenamedSeeDocs = ();
15+
16+
#[cfg(all(feature = "security-framework", not(feature = "with-security-framework")))]
17+
const _CHECK: SecurityFrameworkFeatureRenamedSeeDocs = ();
18+
19+
#[cfg(all(feature = "serde_json", not(feature = "with-serde_json")))]
20+
const _CHECK: SerdeJsonFeatureRenamedSeeDocs = ();
21+
22+
#[cfg(all(feature = "time", not(feature = "with-time")))]
23+
const _CHECK: TimeFeatureRenamedSeeDocs = ();
24+
25+
#[cfg(all(feature = "unix_socket", not(feature = "with-unix_socket")))]
26+
const _CHECK: UnixSocketFeatureRenamedSeeDocs = ();
27+
28+
#[cfg(all(feature = "uuid", not(feature = "with-uuid")))]
29+
const _CHECK: UuidFeatureRenamedSeeDocs = ();

src/io/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@ use std::fmt;
77

88
#[cfg(feature = "with-openssl")]
99
pub mod openssl;
10-
#[cfg(feature = "security-framework")]
10+
#[cfg(feature = "with-security-framework")]
1111
pub mod security_framework;
1212

13-
#[cfg(all(feature = "openssl", not(feature = "with-openssl")))]
14-
const _CHECK: OpensslFeatureRenamedSeeDocs = "";
15-
1613
/// A trait implemented by TLS adaptors.
1714
pub trait TlsStream: fmt::Debug + Read + Write + Send {
1815
/// Returns a reference to the underlying `Stream`.

src/io/security_framework.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl TlsStream for SslStream<Stream> {
1717

1818
/// A `TlsHandshake` implementation that uses the Security Framework.
1919
///
20-
/// Requires the `security-framework` feature.
20+
/// Requires the `with-security-framework` feature.
2121
#[derive(Debug)]
2222
pub struct SecurityFramework(ClientBuilder);
2323

src/lib.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ extern crate hex;
4949
#[macro_use]
5050
extern crate log;
5151
extern crate phf;
52-
#[cfg(feature = "unix_socket")]
52+
#[cfg(feature = "with-unix_socket")]
5353
extern crate unix_socket;
5454

5555
use bufstream::BufStream;
@@ -64,7 +64,7 @@ use std::mem;
6464
use std::result;
6565
use std::sync::Arc;
6666
use std::time::Duration;
67-
#[cfg(any(feature = "unix_socket", all(unix, feature = "nightly")))]
67+
#[cfg(any(feature = "with-unix_socket", all(unix, feature = "nightly")))]
6868
use std::path::PathBuf;
6969

7070
use error::{Error, ConnectError, SqlState, DbError};
@@ -81,6 +81,7 @@ use transaction::{Transaction, IsolationLevel};
8181
#[macro_use]
8282
mod macros;
8383

84+
mod feature_check;
8485
mod md5;
8586
mod message;
8687
mod priv_io;
@@ -165,14 +166,14 @@ impl<'a> IntoConnectParams for &'a str {
165166

166167
impl IntoConnectParams for Url {
167168
fn into_connect_params(self) -> result::Result<ConnectParams, Box<StdError + Sync + Send>> {
168-
#[cfg(any(feature = "unix_socket", all(unix, feature = "nightly")))]
169+
#[cfg(any(feature = "with-unix_socket", all(unix, feature = "nightly")))]
169170
fn make_unix(maybe_path: String)
170171
-> result::Result<ConnectTarget, Box<StdError + Sync + Send>> {
171172
Ok(ConnectTarget::Unix(PathBuf::from(maybe_path)))
172173
}
173-
#[cfg(not(any(feature = "unix_socket", all(unix, feature = "nightly"))))]
174+
#[cfg(not(any(feature = "with-unix_socket", all(unix, feature = "nightly"))))]
174175
fn make_unix(_: String) -> result::Result<ConnectTarget, Box<StdError + Sync + Send>> {
175-
Err("unix socket support requires the `unix_socket` or `nightly` features".into())
176+
Err("unix socket support requires the `with-unix_socket` or `nightly` features".into())
176177
}
177178

178179
let Url { host, port, user, path: url::Path { mut path, query: options, .. }, .. } = self;
@@ -983,13 +984,13 @@ impl Connection {
983984
/// (5432) is used if none is specified. The database name defaults to the
984985
/// username if not specified.
985986
///
986-
/// Connection via Unix sockets is supported with either the `unix_socket`
987-
/// or `nightly` features. To connect to the server via Unix sockets, `host`
988-
/// should be set to the absolute path of the directory containing the
989-
/// socket file. Since `/` is a reserved character in URLs, the path should
990-
/// be URL encoded. If the path contains non-UTF 8 characters, a
991-
/// `ConnectParams` struct should be created manually and passed in. Note
992-
/// that Postgres does not support SSL over Unix sockets.
987+
/// Connection via Unix sockets is supported with either the
988+
/// `with-unix_socket` or `nightly` features. To connect to the server via
989+
/// Unix sockets, `host` should be set to the absolute path of the directory
990+
/// containing the socket file. Since `/` is a reserved character in URLs,
991+
/// the path should be URL encoded. If the path contains non-UTF 8
992+
/// characters, a `ConnectParams` struct should be created manually and
993+
/// passed in. Note that Postgres does not support SSL over Unix sockets.
993994
///
994995
/// # Examples
995996
///
@@ -1011,7 +1012,7 @@ impl Connection {
10111012
/// use postgres::{Connection, UserInfo, ConnectParams, TlsMode, ConnectTarget};
10121013
/// # use std::path::PathBuf;
10131014
///
1014-
/// # #[cfg(feature = "unix_socket")]
1015+
/// # #[cfg(feature = "with-unix_socket")]
10151016
/// # fn f() {
10161017
/// # let some_crazy_path = PathBuf::new();
10171018
/// let params = ConnectParams {

src/priv_io.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ use std::fmt;
66
use std::net::TcpStream;
77
use std::time::Duration;
88
use bufstream::BufStream;
9-
#[cfg(feature = "unix_socket")]
9+
#[cfg(feature = "with-unix_socket")]
1010
use unix_socket::UnixStream;
11-
#[cfg(all(not(feature = "unix_socket"), all(unix, feature = "nightly")))]
11+
#[cfg(all(not(feature = "with-unix_socket"), all(unix, feature = "nightly")))]
1212
use std::os::unix::net::UnixStream;
1313
#[cfg(unix)]
1414
use std::os::unix::io::{AsRawFd, RawFd};
@@ -33,15 +33,15 @@ impl StreamOptions for BufStream<Box<TlsStream>> {
3333
fn set_read_timeout(&self, timeout: Option<Duration>) -> io::Result<()> {
3434
match self.get_ref().get_ref().0 {
3535
InternalStream::Tcp(ref s) => s.set_read_timeout(timeout),
36-
#[cfg(any(feature = "unix_socket", all(unix, feature = "nightly")))]
36+
#[cfg(any(feature = "with-unix_socket", all(unix, feature = "nightly")))]
3737
InternalStream::Unix(ref s) => s.set_read_timeout(timeout),
3838
}
3939
}
4040

4141
fn set_nonblocking(&self, nonblock: bool) -> io::Result<()> {
4242
match self.get_ref().get_ref().0 {
4343
InternalStream::Tcp(ref s) => s.set_nonblocking(nonblock),
44-
#[cfg(any(feature = "unix_socket", all(unix, feature = "nightly")))]
44+
#[cfg(any(feature = "with-unix_socket", all(unix, feature = "nightly")))]
4545
InternalStream::Unix(ref s) => s.set_nonblocking(nonblock),
4646
}
4747
}
@@ -57,7 +57,7 @@ impl fmt::Debug for Stream {
5757
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
5858
match self.0 {
5959
InternalStream::Tcp(ref s) => fmt::Debug::fmt(s, fmt),
60-
#[cfg(any(feature = "unix_socket", all(unix, feature = "nightly")))]
60+
#[cfg(any(feature = "with-unix_socket", all(unix, feature = "nightly")))]
6161
InternalStream::Unix(ref s) => fmt::Debug::fmt(s, fmt),
6262
}
6363
}
@@ -94,7 +94,7 @@ impl AsRawFd for Stream {
9494
fn as_raw_fd(&self) -> RawFd {
9595
match self.0 {
9696
InternalStream::Tcp(ref s) => s.as_raw_fd(),
97-
#[cfg(any(feature = "unix_socket", all(unix, feature = "nightly")))]
97+
#[cfg(any(feature = "with-unix_socket", all(unix, feature = "nightly")))]
9898
InternalStream::Unix(ref s) => s.as_raw_fd(),
9999
}
100100
}
@@ -112,15 +112,15 @@ impl AsRawSocket for Stream {
112112

113113
enum InternalStream {
114114
Tcp(TcpStream),
115-
#[cfg(any(feature = "unix_socket", all(unix, feature = "nightly")))]
115+
#[cfg(any(feature = "with-unix_socket", all(unix, feature = "nightly")))]
116116
Unix(UnixStream),
117117
}
118118

119119
impl Read for InternalStream {
120120
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
121121
match *self {
122122
InternalStream::Tcp(ref mut s) => s.read(buf),
123-
#[cfg(any(feature = "unix_socket", all(unix, feature = "nightly")))]
123+
#[cfg(any(feature = "with-unix_socket", all(unix, feature = "nightly")))]
124124
InternalStream::Unix(ref mut s) => s.read(buf),
125125
}
126126
}
@@ -130,15 +130,15 @@ impl Write for InternalStream {
130130
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
131131
match *self {
132132
InternalStream::Tcp(ref mut s) => s.write(buf),
133-
#[cfg(any(feature = "unix_socket", all(unix, feature = "nightly")))]
133+
#[cfg(any(feature = "with-unix_socket", all(unix, feature = "nightly")))]
134134
InternalStream::Unix(ref mut s) => s.write(buf),
135135
}
136136
}
137137

138138
fn flush(&mut self) -> io::Result<()> {
139139
match *self {
140140
InternalStream::Tcp(ref mut s) => s.flush(),
141-
#[cfg(any(feature = "unix_socket", all(unix, feature = "nightly")))]
141+
#[cfg(any(feature = "with-unix_socket", all(unix, feature = "nightly")))]
142142
InternalStream::Unix(ref mut s) => s.flush(),
143143
}
144144
}
@@ -150,7 +150,7 @@ fn open_socket(params: &ConnectParams) -> Result<InternalStream, ConnectError> {
150150
ConnectTarget::Tcp(ref host) => {
151151
Ok(try!(TcpStream::connect(&(&**host, port)).map(InternalStream::Tcp)))
152152
}
153-
#[cfg(any(feature = "unix_socket", all(unix, feature = "nightly")))]
153+
#[cfg(any(feature = "with-unix_socket", all(unix, feature = "nightly")))]
154154
ConnectTarget::Unix(ref path) => {
155155
let path = path.join(&format!(".s.PGSQL.{}", port));
156156
Ok(try!(UnixStream::connect(&path).map(InternalStream::Unix)))
@@ -184,7 +184,7 @@ pub fn initialize_stream(params: &ConnectParams,
184184
// Postgres doesn't support SSL over unix sockets
185185
let host = match params.target {
186186
ConnectTarget::Tcp(ref host) => host,
187-
#[cfg(any(feature = "unix_socket", all(unix, feature = "nightly")))]
187+
#[cfg(any(feature = "with-unix_socket", all(unix, feature = "nightly")))]
188188
ConnectTarget::Unix(_) => return Err(ConnectError::Io(::bad_response())),
189189
};
190190

src/types/mod.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,19 @@ pub fn __to_sql_checked<T>(v: &T, ty: &Type, out: &mut Write, ctx: &SessionInfo)
5454
v.to_sql(ty, out, ctx)
5555
}
5656

57-
#[cfg(feature = "bit-vec")]
57+
#[cfg(feature = "with-bit-vec")]
5858
mod bit_vec;
59-
#[cfg(feature = "uuid")]
59+
#[cfg(feature = "with-uuid")]
6060
mod uuid;
61-
#[cfg(feature = "time")]
61+
#[cfg(feature = "with-time")]
6262
mod time;
63-
#[cfg(feature = "rustc-serialize")]
63+
#[cfg(feature = "with-rustc-serialize")]
6464
mod rustc_serialize;
65-
#[cfg(feature = "serde_json")]
65+
#[cfg(feature = "with-serde_json")]
6666
mod serde_json;
67-
#[cfg(feature = "chrono")]
67+
#[cfg(feature = "with-chrono")]
6868
mod chrono;
69-
#[cfg(feature = "eui48")]
69+
#[cfg(feature = "with-eui48")]
7070
mod eui48;
7171

7272
mod special;
@@ -273,8 +273,8 @@ impl WrongTypeNew for WrongType {
273273
/// In addition, some implementations are provided for types in third party
274274
/// crates. These are disabled by default; to opt into one of these
275275
/// implementations, activate the Cargo feature corresponding to the crate's
276-
/// name. For example, the `serde_json` feature enables the implementation for
277-
/// the `serde_json::Value` type.
276+
/// name prefixed by `with-`. For example, the `with-serde_json` feature enables
277+
/// the implementation for the `serde_json::Value` type.
278278
///
279279
/// | Rust type | Postgres type(s) |
280280
/// |---------------------------------|-------------------------------------|
@@ -525,8 +525,8 @@ pub enum IsNull {
525525
/// In addition, some implementations are provided for types in third party
526526
/// crates. These are disabled by default; to opt into one of these
527527
/// implementations, activate the Cargo feature corresponding to the crate's
528-
/// name. For example, the `serde_json` feature enables the implementation for
529-
/// the `serde_json::Value` type.
528+
/// name prefixed by `with-`. For example, the `with-serde_json` feature enables
529+
/// the implementation for the `serde_json::Value` type.
530530
///
531531
/// | Rust type | Postgres type(s) |
532532
/// |---------------------------------|-------------------------------------|

0 commit comments

Comments
 (0)