Skip to content

Commit b7a2641

Browse files
authored
Change "tls" feature to "native-tls" (#201)
Change "tls" feature to "native-tls" for clarity and obvious distinction with rustls-tls.
1 parent 55cd646 commit b7a2641

File tree

8 files changed

+29
-28
lines changed

8 files changed

+29
-28
lines changed

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ keywords = ["email", "imap"]
1414
categories = ["email", "network-programming"]
1515

1616
[features]
17-
tls = ["native-tls"]
1817
rustls-tls = ["rustls-connector"]
19-
default = ["tls"]
18+
default = ["native-tls"]
2019

2120
[dependencies]
2221
native-tls = { version = "0.2.2", optional = true }

src/client.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ impl<T: Read + Write> Client<T> {
284284
/// # use imap::Client;
285285
/// # use std::io;
286286
/// # use std::net::TcpStream;
287-
/// # {} #[cfg(feature = "tls")]
287+
/// # {} #[cfg(feature = "native-tls")]
288288
/// # fn main() {
289289
/// # let server = "imap.example.com";
290290
/// # let username = "";
@@ -325,7 +325,7 @@ impl<T: Read + Write> Client<T> {
325325
/// transferred back to the caller.
326326
///
327327
/// ```rust,no_run
328-
/// # {} #[cfg(feature = "tls")]
328+
/// # {} #[cfg(feature = "native-tls")]
329329
/// # fn main() {
330330
/// let client = imap::ClientBuilder::new("imap.example.org", 993)
331331
/// .native_tls().unwrap();
@@ -376,7 +376,7 @@ impl<T: Read + Write> Client<T> {
376376
/// }
377377
/// }
378378
///
379-
/// # {} #[cfg(feature = "tls")]
379+
/// # {} #[cfg(feature = "native-tls")]
380380
/// fn main() {
381381
/// let auth = OAuth2 {
382382
/// user: String::from("me@example.com"),

src/client_builder.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::{Client, Result};
22
use std::io::{Read, Write};
33
use std::net::TcpStream;
44

5-
#[cfg(feature = "tls")]
5+
#[cfg(feature = "native-tls")]
66
use native_tls::{TlsConnector, TlsStream};
77
#[cfg(feature = "rustls-tls")]
88
use rustls_connector::{RustlsConnector, TlsStream as RustlsStream};
@@ -12,7 +12,7 @@ use rustls_connector::{RustlsConnector, TlsStream as RustlsStream};
1212
/// Creating a [`Client`] using `native-tls` transport is straightforward:
1313
/// ```no_run
1414
/// # use imap::ClientBuilder;
15-
/// # {} #[cfg(feature = "tls")]
15+
/// # {} #[cfg(feature = "native-tls")]
1616
/// # fn main() -> Result<(), imap::Error> {
1717
/// let client = ClientBuilder::new("imap.example.com", 993).native_tls()?;
1818
/// # Ok(())
@@ -66,15 +66,15 @@ where
6666
}
6767

6868
/// Use [`STARTTLS`](https://tools.ietf.org/html/rfc2595) for this connection.
69-
#[cfg(any(feature = "tls", feature = "rustls-tls"))]
69+
#[cfg(any(feature = "native-tls", feature = "rustls-tls"))]
7070
pub fn starttls(&mut self) -> &mut Self {
7171
self.starttls = true;
7272
self
7373
}
7474

7575
/// Return a new [`Client`] using a `native-tls` transport.
76-
#[cfg(feature = "tls")]
77-
#[cfg_attr(docsrs, doc(cfg(feature = "tls")))]
76+
#[cfg(feature = "native-tls")]
77+
#[cfg_attr(docsrs, doc(cfg(feature = "native-tls")))]
7878
pub fn native_tls(&mut self) -> Result<Client<TlsStream<TcpStream>>> {
7979
self.connect(|domain, tcp| {
8080
let ssl_conn = TlsConnector::builder().build()?;

src/error.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ use std::str::Utf8Error;
1010
use base64::DecodeError;
1111
use bufstream::IntoInnerError as BufError;
1212
use imap_proto::{types::ResponseCode, Response};
13-
#[cfg(feature = "tls")]
13+
#[cfg(feature = "native-tls")]
1414
use native_tls::Error as TlsError;
15-
#[cfg(feature = "tls")]
15+
#[cfg(feature = "native-tls")]
1616
use native_tls::HandshakeError as TlsHandshakeError;
1717
#[cfg(feature = "rustls-tls")]
1818
use rustls_connector::HandshakeError as RustlsHandshakeError;
@@ -62,10 +62,10 @@ pub enum Error {
6262
#[cfg(feature = "rustls-tls")]
6363
RustlsHandshake(RustlsHandshakeError<TcpStream>),
6464
/// An error from the `native_tls` library during the TLS handshake.
65-
#[cfg(feature = "tls")]
65+
#[cfg(feature = "native-tls")]
6666
TlsHandshake(TlsHandshakeError<TcpStream>),
6767
/// An error from the `native_tls` library while managing the socket.
68-
#[cfg(feature = "tls")]
68+
#[cfg(feature = "native-tls")]
6969
Tls(TlsError),
7070
/// A BAD response from the IMAP server.
7171
Bad(Bad),
@@ -114,14 +114,14 @@ impl From<RustlsHandshakeError<TcpStream>> for Error {
114114
}
115115
}
116116

117-
#[cfg(feature = "tls")]
117+
#[cfg(feature = "native-tls")]
118118
impl From<TlsHandshakeError<TcpStream>> for Error {
119119
fn from(err: TlsHandshakeError<TcpStream>) -> Error {
120120
Error::TlsHandshake(err)
121121
}
122122
}
123123

124-
#[cfg(feature = "tls")]
124+
#[cfg(feature = "native-tls")]
125125
impl From<TlsError> for Error {
126126
fn from(err: TlsError) -> Error {
127127
Error::Tls(err)
@@ -140,9 +140,9 @@ impl fmt::Display for Error {
140140
Error::Io(ref e) => fmt::Display::fmt(e, f),
141141
#[cfg(feature = "rustls-tls")]
142142
Error::RustlsHandshake(ref e) => fmt::Display::fmt(e, f),
143-
#[cfg(feature = "tls")]
143+
#[cfg(feature = "native-tls")]
144144
Error::Tls(ref e) => fmt::Display::fmt(e, f),
145-
#[cfg(feature = "tls")]
145+
#[cfg(feature = "native-tls")]
146146
Error::TlsHandshake(ref e) => fmt::Display::fmt(e, f),
147147
Error::Validate(ref e) => fmt::Display::fmt(e, f),
148148
Error::Parse(ref e) => fmt::Display::fmt(e, f),
@@ -163,9 +163,9 @@ impl StdError for Error {
163163
Error::Io(ref e) => e.description(),
164164
#[cfg(feature = "rustls-tls")]
165165
Error::RustlsHandshake(ref e) => e.description(),
166-
#[cfg(feature = "tls")]
166+
#[cfg(feature = "native-tls")]
167167
Error::Tls(ref e) => e.description(),
168-
#[cfg(feature = "tls")]
168+
#[cfg(feature = "native-tls")]
169169
Error::TlsHandshake(ref e) => e.description(),
170170
Error::Parse(ref e) => e.description(),
171171
Error::Validate(ref e) => e.description(),
@@ -183,9 +183,9 @@ impl StdError for Error {
183183
Error::Io(ref e) => Some(e),
184184
#[cfg(feature = "rustls-tls")]
185185
Error::RustlsHandshake(ref e) => Some(e),
186-
#[cfg(feature = "tls")]
186+
#[cfg(feature = "native-tls")]
187187
Error::Tls(ref e) => Some(e),
188-
#[cfg(feature = "tls")]
188+
#[cfg(feature = "native-tls")]
189189
Error::TlsHandshake(ref e) => Some(e),
190190
Error::Parse(ParseError::DataNotUtf8(_, ref e)) => Some(e),
191191
_ => None,

src/extensions/idle.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::client::Session;
55
use crate::error::{Error, Result};
66
use crate::parse::parse_idle;
77
use crate::types::UnsolicitedResponse;
8-
#[cfg(feature = "tls")]
8+
#[cfg(feature = "native-tls")]
99
use native_tls::TlsStream;
1010
#[cfg(feature = "rustls-tls")]
1111
use rustls_connector::TlsStream as RustlsStream;
@@ -28,7 +28,7 @@ use std::time::Duration;
2828
///
2929
/// ```no_run
3030
/// use imap::extensions::idle;
31-
/// # #[cfg(feature = "tls")]
31+
/// # #[cfg(feature = "native-tls")]
3232
/// # {
3333
/// let client = imap::ClientBuilder::new("example.com", 993).native_tls()
3434
/// .expect("Could not connect to imap server");
@@ -281,7 +281,7 @@ impl<'a> SetReadTimeout for TcpStream {
281281
}
282282
}
283283

284-
#[cfg(feature = "tls")]
284+
#[cfg(feature = "native-tls")]
285285
impl<'a> SetReadTimeout for TlsStream<TcpStream> {
286286
fn set_read_timeout(&mut self, timeout: Option<Duration>) -> Result<()> {
287287
self.get_ref().set_read_timeout(timeout).map_err(Error::Io)

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
//! Below is a basic client example. See the `examples/` directory for more.
2222
//!
2323
//! ```no_run
24-
//! # #[cfg(feature = "tls")]
24+
//! # #[cfg(feature = "native-tls")]
2525
//! fn fetch_inbox_top() -> imap::error::Result<Option<String>> {
2626
//!
2727
//! let client = imap::ClientBuilder::new("imap.example.com", 993).native_tls()?;

src/types/deleted.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use std::ops::RangeInclusive;
1818
///
1919
/// # Examples
2020
/// ```no_run
21-
/// # {} #[cfg(feature = "tls")]
21+
/// # {} #[cfg(feature = "native-tls")]
2222
/// # fn main() {
2323
/// # let client = imap::ClientBuilder::new("imap.example.com", 993)
2424
/// .native_tls().unwrap();

tests/imap_integration.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,9 @@ fn status() {
456456

457457
// Test all valid fields except HIGHESTMODSEQ, which apparently
458458
// isn't supported by the IMAP server used for this test.
459-
let mb = s.status("INBOX", "(MESSAGES RECENT UIDNEXT UIDVALIDITY UNSEEN)").unwrap();
459+
let mb = s
460+
.status("INBOX", "(MESSAGES RECENT UIDNEXT UIDVALIDITY UNSEEN)")
461+
.unwrap();
460462
assert_eq!(mb.flags, Vec::new());
461463
assert_eq!(mb.exists, 0);
462464
assert_eq!(mb.recent, 0);

0 commit comments

Comments
 (0)