Skip to content

Commit 43ed1b1

Browse files
committed
Simplify feature flags. Include pools by default
1 parent 0fc4c67 commit 43ed1b1

File tree

5 files changed

+28
-72
lines changed

5 files changed

+28
-72
lines changed

Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@ version = "0.7.0-alpha.3"
1616
[features]
1717
default = ["sync"]
1818
# sync
19-
sync = ["pool"]
20-
pool = ["r2d2"]
19+
sync = ["r2d2"]
2120
# sync TLS
2221
ssl = ["openssl"]
2322
sslv = ["openssl/vendored"]
2423
# async
25-
aio = ["bytes", "tokio", "aio-pool"]
26-
aio-pool = ["bb8", "async-trait"]
24+
aio = ["bytes", "tokio", "bb8", "async-trait"]
2725
# async TLS
2826
aio-ssl = ["tokio-openssl", "openssl"]
2927
aio-sslv = ["tokio-openssl", "openssl/vendored"]

ret.rs

Whitespace-only changes.

src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,7 @@ mod util;
217217
pub mod actions;
218218
pub mod ddl;
219219
pub mod error;
220-
cfg_pool_any! {
221-
pub mod pool;
222-
}
220+
pub mod pool;
223221
pub mod types;
224222
// endof public mods
225223
// private mods

src/pool.rs

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
125125
// re-exports
126126
// sync
127-
cfg_sync_pool! {
127+
cfg_sync! {
128128
/// [`r2d2`](https://docs.rs/r2d2)'s error type
129129
pub use r2d2::Error as r2d2Error;
130130
pub use self::sync_impls::Pool;
@@ -134,20 +134,21 @@ cfg_sync_pool! {
134134
.max_size(max_size)
135135
.build(ConnectionManager::new_notls(host.to_string(), port))
136136
}
137-
cfg_sync_ssl_any! {
138-
pub use self::sync_impls::TlsPool;
139-
/// Returns a TLS pool of the specified size and provided settings
140-
pub fn get_tls(host: impl ToString, port: u16, cert: impl ToString, max_size: u32) -> Result<TlsPool, r2d2Error> {
141-
TlsPool::builder()
142-
.max_size(max_size)
143-
.build(
144-
ConnectionManager::new_tls(host.to_string(), port, cert)
145-
)
146-
}
137+
}
138+
cfg_sync_ssl_any! {
139+
pub use self::sync_impls::TlsPool;
140+
/// Returns a TLS pool of the specified size and provided settings
141+
pub fn get_tls(host: impl ToString, port: u16, cert: impl ToString, max_size: u32) -> Result<TlsPool, r2d2Error> {
142+
TlsPool::builder()
143+
.max_size(max_size)
144+
.build(
145+
ConnectionManager::new_tls(host.to_string(), port, cert)
146+
)
147147
}
148148
}
149+
149150
// async
150-
cfg_async_pool! {
151+
cfg_async! {
151152
/// [`bb8`](https://docs.rs/bb8)'s error type
152153
pub use bb8::RunError as bb8Error;
153154
pub use self::async_impls::Pool as AsyncPool;
@@ -158,14 +159,14 @@ cfg_async_pool! {
158159
.max_size(max_size)
159160
.build(ConnectionManager::new_notls(host.to_string(), port)).await
160161
}
161-
cfg_async_ssl_any! {
162-
pub use self::async_impls::TlsPool as AsyncTlsPool;
163-
/// Returns an async TLS pool of the specified size and provided settings
164-
pub async fn get_tls_async(host: impl ToString, port: u16, cert: impl ToString, max_size: u32) -> Result<AsyncTlsPool, Error> {
165-
AsyncTlsPool::builder()
166-
.max_size(max_size)
167-
.build(ConnectionManager::new_tls(host.to_string(), port, cert)).await
168-
}
162+
}
163+
cfg_async_ssl_any! {
164+
pub use self::async_impls::TlsPool as AsyncTlsPool;
165+
/// Returns an async TLS pool of the specified size and provided settings
166+
pub async fn get_tls_async(host: impl ToString, port: u16, cert: impl ToString, max_size: u32) -> Result<AsyncTlsPool, Error> {
167+
AsyncTlsPool::builder()
168+
.max_size(max_size)
169+
.build(ConnectionManager::new_tls(host.to_string(), port, cert)).await
169170
}
170171
}
171172

@@ -203,7 +204,8 @@ impl<C> ConnectionManager<C> {
203204
}
204205
}
205206

206-
#[cfg(any(feature = "sync", feature = "pool"))]
207+
#[cfg(feature = "sync")]
208+
#[cfg_attr(docsrs, doc(cfg(feature = "sync")))]
207209
mod sync_impls {
208210
use super::ConnectionManager;
209211
use crate::sync::Connection as SyncConnection;
@@ -274,7 +276,8 @@ mod sync_impls {
274276
}
275277
}
276278

277-
#[cfg(any(feature = "aio", feature = "aio-pool"))]
279+
#[cfg(feature = "aio")]
280+
#[cfg_attr(docsrs, doc(cfg(feature = "aio")))]
278281
mod async_impls {
279282
use super::ConnectionManager;
280283
use crate::aio::Connection as AsyncConnection;

src/util.rs

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,6 @@ macro_rules! cfg_sync {
8181
};
8282
}
8383

84-
macro_rules! cfg_sync_pool {
85-
($($body:item)*) => {
86-
$(
87-
#[cfg(all(feature = "sync", feature= "pool"))]
88-
#[cfg_attr(docsrs, doc(cfg(all(feature = "sync", feature = "pool"))))]
89-
$body
90-
)*
91-
};
92-
}
93-
9484
macro_rules! cfg_async {
9585
($($body:item)*) => {
9686
$(
@@ -101,16 +91,6 @@ macro_rules! cfg_async {
10191
};
10292
}
10393

104-
macro_rules! cfg_async_pool {
105-
($($body:item)*) => {
106-
$(
107-
#[cfg(all(feature = "aio", feature= "aio-pool"))]
108-
#[cfg_attr(docsrs, doc(cfg(all(feature = "aio", feature = "aio-pool"))))]
109-
$body
110-
)*
111-
};
112-
}
113-
11494
macro_rules! cfg_dbg {
11595
($($body:item)*) => {
11696
$(
@@ -120,26 +100,3 @@ macro_rules! cfg_dbg {
120100
)*
121101
};
122102
}
123-
124-
macro_rules! cfg_pool_any {
125-
($($body:item)*) => {
126-
$(
127-
#[cfg(any(
128-
feature = "sync",
129-
feature = "pool",
130-
feature = "aio",
131-
feature = "aio-pool"
132-
))]
133-
#[cfg_attr(
134-
docsrs,
135-
doc(cfg(any(
136-
feature = "sync",
137-
feature = "pool",
138-
feature = "aio",
139-
feature = "aio-pool"
140-
)))
141-
)]
142-
$body
143-
)*
144-
};
145-
}

0 commit comments

Comments
 (0)