Skip to content

Commit 9fb0d8b

Browse files
committed
Rename tls feature into _tls
1 parent f7ef075 commit 9fb0d8b

File tree

8 files changed

+40
-40
lines changed

8 files changed

+40
-40
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ exclude = ["tests/*", "examples/*"]
1515

1616
[features]
1717
default = ["tokio_io"]
18-
tls = [] # meta feature for the clickhouse-rs generic TLS code
19-
tls-native-tls = ["tokio-native-tls", "native-tls", "tls"]
20-
tls-rustls = ["tokio-rustls", "rustls", "rustls-pemfile", "tls"]
18+
_tls = [] # meta feature for the clickhouse-rs generic TLS code
19+
tls-native-tls = ["tokio-native-tls", "native-tls", "_tls"]
20+
tls-rustls = ["tokio-rustls", "rustls", "rustls-pemfile", "_tls"]
2121
async_std = ["async-std"]
2222
tokio_io = ["tokio"]
2323

examples/simple.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ async fn execute(database_url: String) -> Result<(), Box<dyn Error>> {
3838
Ok(())
3939
}
4040

41-
#[cfg(all(feature = "tokio_io", not(feature = "tls")))]
41+
#[cfg(all(feature = "tokio_io", not(feature = "_tls")))]
4242
#[tokio::main]
4343
async fn main() -> Result<(), Box<dyn Error>> {
4444
let database_url =
4545
env::var("DATABASE_URL").unwrap_or_else(|_| "tcp://localhost:9000?compression=lz4".into());
4646
execute(database_url).await
4747
}
4848

49-
#[cfg(all(feature = "tokio_io", feature = "tls"))]
49+
#[cfg(all(feature = "tokio_io", feature = "_tls"))]
5050
#[tokio::main]
5151
async fn main() -> Result<(), Box<dyn Error>> {
5252
let database_url = env::var("DATABASE_URL")

src/connecting_stream.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::{
66
};
77

88
use futures_util::future::{select_ok, BoxFuture, SelectOk, TryFutureExt};
9-
#[cfg(feature = "tls")]
9+
#[cfg(feature = "_tls")]
1010
use futures_util::FutureExt;
1111

1212
#[cfg(feature = "async_std")]
@@ -46,7 +46,7 @@ enum TcpState {
4646
Fail(Option<ConnectionError>),
4747
}
4848

49-
#[cfg(feature = "tls")]
49+
#[cfg(feature = "_tls")]
5050
#[pin_project(project = TlsStateProj)]
5151
enum TlsState {
5252
Wait(#[pin] ConnectingFuture<TlsStream<TcpStream>>),
@@ -56,7 +56,7 @@ enum TlsState {
5656
#[pin_project(project = StateProj)]
5757
enum State {
5858
Tcp(#[pin] TcpState),
59-
#[cfg(feature = "tls")]
59+
#[cfg(feature = "_tls")]
6060
Tls(#[pin] TlsState),
6161
}
6262

@@ -73,7 +73,7 @@ impl TcpState {
7373
}
7474
}
7575

76-
#[cfg(feature = "tls")]
76+
#[cfg(feature = "_tls")]
7777
impl TlsState {
7878
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<InnerStream>> {
7979
match self.project() {
@@ -94,7 +94,7 @@ impl State {
9494
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<InnerStream>> {
9595
match self.project() {
9696
StateProj::Tcp(inner) => inner.poll(cx),
97-
#[cfg(feature = "tls")]
97+
#[cfg(feature = "_tls")]
9898
StateProj::Tls(inner) => inner.poll(cx),
9999
}
100100
}
@@ -104,7 +104,7 @@ impl State {
104104
State::Tcp(TcpState::Fail(Some(conn_error)))
105105
}
106106

107-
#[cfg(feature = "tls")]
107+
#[cfg(feature = "_tls")]
108108
fn tls_host_err() -> Self {
109109
State::Tls(TlsState::Fail(Some(ConnectionError::TlsHostNotProvided)))
110110
}
@@ -113,7 +113,7 @@ impl State {
113113
State::Tcp(TcpState::Wait(socket))
114114
}
115115

116-
#[cfg(feature = "tls")]
116+
#[cfg(feature = "_tls")]
117117
fn tls_wait(s: ConnectingFuture<TlsStream<TcpStream>>) -> Self {
118118
State::Tls(TlsState::Wait(s))
119119
}
@@ -201,7 +201,7 @@ impl ConnectingStream {
201201

202202
let socket = select_ok(streams);
203203

204-
#[cfg(feature = "tls")]
204+
#[cfg(feature = "_tls")]
205205
{
206206
if options.secure {
207207
return ConnectingStream::new_tls_connection(addr, socket, options);

src/errors/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub enum ConnectionError {
6060
#[error("Input/output error: `{}`", _0)]
6161
IoError(#[source] io::Error),
6262

63-
#[cfg(feature = "tls")]
63+
#[cfg(feature = "_tls")]
6464
#[error("TLS connection error: `{}`", _0)]
6565
TlsError(#[source] TlsError),
6666

@@ -142,7 +142,7 @@ impl From<ConnectionError> for Error {
142142
}
143143
}
144144

145-
#[cfg(feature = "tls")]
145+
#[cfg(feature = "_tls")]
146146
impl From<TlsError> for ConnectionError {
147147
fn from(error: TlsError) -> Self {
148148
ConnectionError::TlsError(error)

src/io/stream.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ use pin_project::pin_project;
2020
#[cfg(feature = "tokio_io")]
2121
use tokio::io::{AsyncRead, AsyncWrite};
2222

23-
#[cfg(all(feature = "tls", feature = "tokio_io"))]
23+
#[cfg(all(feature = "_tls", feature = "tokio_io"))]
2424
type SecureTcpStream = TlsStream<TcpStream>;
2525

2626
#[pin_project(project = StreamProj)]
2727
pub(crate) enum Stream {
2828
Plain(#[pin] TcpStream),
29-
#[cfg(feature = "tls")]
29+
#[cfg(feature = "_tls")]
3030
Secure(#[pin] SecureTcpStream),
3131
}
3232

@@ -36,7 +36,7 @@ impl From<TcpStream> for Stream {
3636
}
3737
}
3838

39-
#[cfg(feature = "tls")]
39+
#[cfg(feature = "_tls")]
4040
impl From<SecureTcpStream> for Stream {
4141
fn from(stream: SecureTcpStream) -> Stream {
4242
Self::Secure(stream)
@@ -57,7 +57,7 @@ impl Stream {
5757
pub(crate) fn set_keepalive(&mut self, keepalive: Option<Duration>) -> io::Result<()> {
5858
// match *self {
5959
// Self::Plain(ref mut stream) => stream.set_keepalive(keepalive),
60-
// #[cfg(feature = "tls")]
60+
// #[cfg(feature = "_tls")]
6161
// Self::Secure(ref mut stream) => stream.get_mut().set_keepalive(keepalive),
6262
// }.map_err(|err| io::Error::new(err.kind(), format!("set_keepalive error: {}", err)))
6363
if keepalive.is_some() {
@@ -88,7 +88,7 @@ impl Stream {
8888
) -> Poll<io::Result<usize>> {
8989
match self.project() {
9090
StreamProj::Plain(stream) => stream.poll_read(cx, buf),
91-
#[cfg(feature = "tls")]
91+
#[cfg(feature = "_tls")]
9292
StreamProj::Secure(stream) => stream.poll_read(cx, buf),
9393
}
9494
}
@@ -103,7 +103,7 @@ impl Stream {
103103

104104
let result = match self.project() {
105105
StreamProj::Plain(stream) => stream.poll_read(cx, &mut read_buf),
106-
#[cfg(feature = "tls")]
106+
#[cfg(feature = "_tls")]
107107
StreamProj::Secure(stream) => stream.poll_read(cx, &mut read_buf),
108108
};
109109

@@ -121,7 +121,7 @@ impl Stream {
121121
) -> Poll<io::Result<usize>> {
122122
match self.project() {
123123
StreamProj::Plain(stream) => stream.poll_write(cx, buf),
124-
#[cfg(feature = "tls")]
124+
#[cfg(feature = "_tls")]
125125
StreamProj::Secure(stream) => stream.poll_write(cx, buf),
126126
}
127127
}

src/pool/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,9 @@ mod test {
377377
let spent = start.elapsed();
378378

379379
assert!(spent >= Duration::from_millis(2000));
380-
#[cfg(feature = "tls")]
380+
#[cfg(feature = "_tls")]
381381
assert!(spent < Duration::from_millis(5000)); // slow connect
382-
#[cfg(not(feature = "tls"))]
382+
#[cfg(not(feature = "_tls"))]
383383
assert!(spent < Duration::from_millis(2500));
384384

385385
assert_eq!(pool.info().idle_len, 6);

src/types/options.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,13 @@ impl From<Certificate> for Vec<rustls::pki_types::CertificateDer<'static>> {
153153
}
154154
}
155155

156-
#[cfg(feature = "tls")]
156+
#[cfg(feature = "_tls")]
157157
impl fmt::Debug for Certificate {
158158
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
159159
write!(f, "[Certificate]")
160160
}
161161
}
162-
#[cfg(feature = "tls")]
162+
#[cfg(feature = "_tls")]
163163
impl PartialEq for Certificate {
164164
fn eq(&self, _other: &Self) -> bool {
165165
true
@@ -280,15 +280,15 @@ pub struct Options {
280280
pub(crate) execute_timeout: Option<Duration>,
281281

282282
/// Enable TLS encryption (defaults to `false`)
283-
#[cfg(feature = "tls")]
283+
#[cfg(feature = "_tls")]
284284
pub(crate) secure: bool,
285285

286286
/// Skip certificate verification (default is `false`).
287-
#[cfg(feature = "tls")]
287+
#[cfg(feature = "_tls")]
288288
pub(crate) skip_verify: bool,
289289

290290
/// An X509 certificate.
291-
#[cfg(feature = "tls")]
291+
#[cfg(feature = "_tls")]
292292
pub(crate) certificate: Option<Certificate>,
293293

294294
/// Query settings
@@ -339,11 +339,11 @@ impl Default for Options {
339339
query_timeout: Duration::from_secs(180),
340340
insert_timeout: Some(Duration::from_secs(180)),
341341
execute_timeout: Some(Duration::from_secs(180)),
342-
#[cfg(feature = "tls")]
342+
#[cfg(feature = "_tls")]
343343
secure: false,
344-
#[cfg(feature = "tls")]
344+
#[cfg(feature = "_tls")]
345345
skip_verify: false,
346-
#[cfg(feature = "tls")]
346+
#[cfg(feature = "_tls")]
347347
certificate: None,
348348
settings: HashMap::new(),
349349
alt_hosts: Vec::new(),
@@ -481,19 +481,19 @@ impl Options {
481481
=> execute_timeout: Option<Duration>
482482
}
483483

484-
#[cfg(feature = "tls")]
484+
#[cfg(feature = "_tls")]
485485
property! {
486486
/// Establish secure connection (default is `false`).
487487
=> secure: bool
488488
}
489489

490-
#[cfg(feature = "tls")]
490+
#[cfg(feature = "_tls")]
491491
property! {
492492
/// Skip certificate verification (default is `false`).
493493
=> skip_verify: bool
494494
}
495495

496-
#[cfg(feature = "tls")]
496+
#[cfg(feature = "_tls")]
497497
property! {
498498
/// An X509 certificate.
499499
=> certificate: Option<Certificate>
@@ -586,9 +586,9 @@ where
586586
options.execute_timeout = parse_param(key, value, parse_opt_duration)?
587587
}
588588
"compression" => options.compression = parse_param(key, value, parse_compression)?,
589-
#[cfg(feature = "tls")]
589+
#[cfg(feature = "_tls")]
590590
"secure" => options.secure = parse_param(key, value, bool::from_str)?,
591-
#[cfg(feature = "tls")]
591+
#[cfg(feature = "_tls")]
592592
"skip_verify" => options.skip_verify = parse_param(key, value, bool::from_str)?,
593593
"alt_hosts" => options.alt_hosts = parse_param(key, value, parse_hosts)?,
594594
_ => {
@@ -727,7 +727,7 @@ mod test {
727727
}
728728

729729
#[test]
730-
#[cfg(feature = "tls")]
730+
#[cfg(feature = "_tls")]
731731
fn test_parse_secure_options() {
732732
let url = "tcp://username:password@host1:9001/database?ping_timeout=42ms&keepalive=99s&compression=lz4&connection_timeout=10s&secure=true&skip_verify=true";
733733
assert_eq!(

tests/clickhouse.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ use std::{
3131
use uuid::Uuid;
3232
use Tz::{Asia__Istanbul as IST, UTC};
3333

34-
#[cfg(not(feature = "tls"))]
34+
#[cfg(not(feature = "_tls"))]
3535
fn database_url() -> String {
3636
env::var("DATABASE_URL").unwrap_or_else(|_| {
3737
"tcp://localhost:9000?compression=lz4&ping_timeout=2s&retry_timeout=3s".into()
3838
})
3939
}
4040

41-
#[cfg(feature = "tls")]
41+
#[cfg(feature = "_tls")]
4242
fn database_url() -> String {
4343
env::var("DATABASE_URL").unwrap_or_else(|_| {
4444
"tcp://localhost:9440?compression=lz4&ping_timeout=2s&retry_timeout=3s&secure=true&skip_verify=true".into()

0 commit comments

Comments
 (0)