Skip to content

Commit cf0aa20

Browse files
feat: update dependencies
1 parent f01a905 commit cf0aa20

File tree

9 files changed

+82
-71
lines changed

9 files changed

+82
-71
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ imap-proto = { git = 'https://github.com/djc/tokio-imap' }
2626
nom = "5.0"
2727
base64 = "0.11"
2828
chrono = "0.4"
29-
async-native-tls = "0.1.1"
30-
native-tls = "0.2.3"
31-
async-std = { version = "1.0", features = ["unstable"] }
29+
async-native-tls = "0.3.0"
30+
async-std = { version = "1.4.0", default-features = false, features = ["std"] }
3231
pin-utils = "0.1.0-alpha.4"
3332
futures = "0.3.0"
3433
async-attributes = "1.1.0"
@@ -45,6 +44,7 @@ rustls-connector = "0.8.0"
4544
rustls = { version = "0.16.0", features = ["dangerous_configuration"] }
4645
webpki = "0.21.0"
4746
pretty_assertions = "0.6.1"
47+
native-tls = "0.2.3"
4848

4949
[[example]]
5050
name = "basic"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ use async_imap::error::Result;
6969

7070
async fn fetch_inbox_top() -> Result<Option<String>> {
7171
let domain = "imap.example.com";
72-
let tls = native_tls::TlsConnector::builder.build().unwrap().into();
72+
let tls = async_native_tls::TlsConnector::new();
7373

7474
// we pass in the domain twice to check that the server's TLS
7575
// certificate is valid for the domain we're connecting to.
76-
let client = async_imap::connect((domain, 993), domain, &tls).await?;
76+
let client = async_imap::connect((domain, 993), domain, tls).await?;
7777

7878
// the client we have here is unauthenticated.
7979
// to do anything useful with the e-mails, we need to log in

examples/basic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ fn main() -> Result<()> {
1818
}
1919

2020
async fn fetch_inbox_top(imap_server: &str, login: &str, password: &str) -> Result<Option<String>> {
21-
let tls = native_tls::TlsConnector::new().unwrap().into();
21+
let tls = async_native_tls::TlsConnector::new();
2222

2323
// we pass in the imap_server twice to check that the server's TLS
2424
// certificate is valid for the imap_server we're connecting to.
25-
let client = async_imap::connect((imap_server, 993), imap_server, &tls).await?;
25+
let client = async_imap::connect((imap_server, 993), imap_server, tls).await?;
2626
println!("-- connected to {}:{}", imap_server, 993);
2727

2828
// the client we have here is unauthenticated.

examples/gmail_oauth2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ fn main() -> Result<()> {
2727
let domain = "imap.gmail.com";
2828
let port = 993;
2929
let socket_addr = (domain, port);
30-
let tls = native_tls::TlsConnector::new().unwrap().into();
31-
let client = async_imap::connect(socket_addr, domain, &tls).await?;
30+
let tls = async_native_tls::TlsConnector::new();
31+
let client = async_imap::connect(socket_addr, domain, tls).await?;
3232

3333
let mut imap_session = match client.authenticate("XOAUTH2", &gmail_auth).await {
3434
Ok(c) => c,

examples/idle.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ fn main() -> Result<()> {
2020
}
2121

2222
async fn fetch_and_idle(imap_server: &str, login: &str, password: &str) -> Result<()> {
23-
let tls = native_tls::TlsConnector::new().unwrap().into();
23+
let tls = async_native_tls::TlsConnector::new();
2424

2525
// we pass in the imap_server twice to check that the server's TLS
2626
// certificate is valid for the imap_server we're connecting to.
27-
let client = async_imap::connect((imap_server, 993), imap_server, &tls).await?;
27+
let client = async_imap::connect((imap_server, 993), imap_server, tls).await?;
2828
println!("-- connected to {}:{}", imap_server, 993);
2929

3030
// the client we have here is unauthenticated.

src/client.rs

Lines changed: 62 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,16 @@ impl<T: Read + Write + Unpin + fmt::Debug> DerefMut for Session<T> {
116116
/// # fn main() -> async_imap::error::Result<()> {
117117
/// # async_std::task::block_on(async {
118118
///
119-
/// let tls = native_tls::TlsConnector::builder().build().unwrap().into();
120-
/// let client = async_imap::connect(("imap.example.org", 993), "imap.example.org", &tls).await?;
119+
/// let tls = async_native_tls::TlsConnector::new();
120+
/// let client = async_imap::connect(("imap.example.org", 993), "imap.example.org", tls).await?;
121121
///
122122
/// # Ok(())
123123
/// # }) }
124124
/// ```
125125
pub async fn connect<A: ToSocketAddrs, S: AsRef<str>>(
126126
addr: A,
127127
domain: S,
128-
ssl_connector: &TlsConnector,
128+
ssl_connector: TlsConnector,
129129
) -> Result<Client<TlsStream<TcpStream>>> {
130130
let stream = TcpStream::connect(addr).await?;
131131
let ssl_stream = ssl_connector.connect(domain.as_ref(), stream).await?;
@@ -134,7 +134,9 @@ pub async fn connect<A: ToSocketAddrs, S: AsRef<str>>(
134134
let _greeting = match client.read_response().await {
135135
Some(greeting) => greeting,
136136
None => {
137-
return Err(Error::Bad("could not read server Greeting after connect"));
137+
return Err(Error::Bad(
138+
"could not read server Greeting after connect".into(),
139+
));
138140
}
139141
};
140142

@@ -148,7 +150,7 @@ impl Client<TcpStream> {
148150
pub async fn secure<S: AsRef<str>>(
149151
mut self,
150152
domain: S,
151-
ssl_connector: &TlsConnector,
153+
ssl_connector: TlsConnector,
152154
) -> Result<Client<TlsStream<TcpStream>>> {
153155
self.run_command_and_check_ok("STARTTLS", None).await?;
154156
let ssl_stream = ssl_connector
@@ -206,11 +208,11 @@ impl<T: Read + Write + Unpin + fmt::Debug> Client<T> {
206208
/// # fn main() -> async_imap::error::Result<()> {
207209
/// # async_std::task::block_on(async {
208210
///
209-
/// let tls = native_tls::TlsConnector::builder().build().unwrap().into();
211+
/// let tls = async_native_tls::TlsConnector::new();
210212
/// let client = async_imap::connect(
211213
/// ("imap.example.org", 993),
212214
/// "imap.example.org",
213-
/// &tls
215+
/// tls
214216
/// ).await?;
215217
///
216218
/// match client.login("user", "pass").await {
@@ -271,8 +273,8 @@ impl<T: Read + Write + Unpin + fmt::Debug> Client<T> {
271273
/// };
272274
///
273275
/// let domain = "imap.example.com";
274-
/// let tls = native_tls::TlsConnector::builder().build().unwrap().into();
275-
/// let client = async_imap::connect((domain, 993), domain, &tls).await?;
276+
/// let tls = async_native_tls::TlsConnector::new();
277+
/// let client = async_imap::connect((domain, 993), domain, tls).await?;
276278
/// match client.authenticate("XOAUTH2", &auth).await {
277279
/// Ok(session) => {
278280
/// // you are successfully authenticated!
@@ -1823,28 +1825,32 @@ mod tests {
18231825

18241826
#[async_attributes::test]
18251827
async fn store() {
1826-
generic_store(" ", |c, set, query| async move {
1827-
c.lock()
1828-
.await
1829-
.store(set, query)
1830-
.await?
1831-
.collect::<Vec<_>>()
1832-
.await;
1833-
Ok(())
1828+
generic_store(" ", |c, set, query| {
1829+
async move {
1830+
c.lock()
1831+
.await
1832+
.store(set, query)
1833+
.await?
1834+
.collect::<Vec<_>>()
1835+
.await;
1836+
Ok(())
1837+
}
18341838
})
18351839
.await;
18361840
}
18371841

18381842
#[async_attributes::test]
18391843
async fn uid_store() {
1840-
generic_store(" UID ", |c, set, query| async move {
1841-
c.lock()
1842-
.await
1843-
.uid_store(set, query)
1844-
.await?
1845-
.collect::<Vec<_>>()
1846-
.await;
1847-
Ok(())
1844+
generic_store(" UID ", |c, set, query| {
1845+
async move {
1846+
c.lock()
1847+
.await
1848+
.uid_store(set, query)
1849+
.await?
1850+
.collect::<Vec<_>>()
1851+
.await;
1852+
Ok(())
1853+
}
18481854
})
18491855
.await;
18501856
}
@@ -1864,18 +1870,22 @@ mod tests {
18641870

18651871
#[async_attributes::test]
18661872
async fn copy() {
1867-
generic_copy(" ", |c, set, query| async move {
1868-
c.lock().await.copy(set, query).await?;
1869-
Ok(())
1873+
generic_copy(" ", |c, set, query| {
1874+
async move {
1875+
c.lock().await.copy(set, query).await?;
1876+
Ok(())
1877+
}
18701878
})
18711879
.await;
18721880
}
18731881

18741882
#[async_attributes::test]
18751883
async fn uid_copy() {
1876-
generic_copy(" UID ", |c, set, query| async move {
1877-
c.lock().await.uid_copy(set, query).await?;
1878-
Ok(())
1884+
generic_copy(" UID ", |c, set, query| {
1885+
async move {
1886+
c.lock().await.uid_copy(set, query).await?;
1887+
Ok(())
1888+
}
18791889
})
18801890
.await;
18811891
}
@@ -1934,29 +1944,33 @@ mod tests {
19341944

19351945
#[async_attributes::test]
19361946
async fn fetch() {
1937-
generic_fetch(" ", |c, seq, query| async move {
1938-
c.lock()
1939-
.await
1940-
.fetch(seq, query)
1941-
.await?
1942-
.collect::<Vec<_>>()
1943-
.await;
1944-
1945-
Ok(())
1947+
generic_fetch(" ", |c, seq, query| {
1948+
async move {
1949+
c.lock()
1950+
.await
1951+
.fetch(seq, query)
1952+
.await?
1953+
.collect::<Vec<_>>()
1954+
.await;
1955+
1956+
Ok(())
1957+
}
19461958
})
19471959
.await;
19481960
}
19491961

19501962
#[async_attributes::test]
19511963
async fn uid_fetch() {
1952-
generic_fetch(" UID ", |c, seq, query| async move {
1953-
c.lock()
1954-
.await
1955-
.uid_fetch(seq, query)
1956-
.await?
1957-
.collect::<Vec<_>>()
1958-
.await;
1959-
Ok(())
1964+
generic_fetch(" UID ", |c, seq, query| {
1965+
async move {
1966+
c.lock()
1967+
.await
1968+
.uid_fetch(seq, query)
1969+
.await?
1970+
.collect::<Vec<_>>()
1971+
.await;
1972+
Ok(())
1973+
}
19601974
})
19611975
.await;
19621976
}

src/error.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub enum Error {
2929
/// strings](https://tools.ietf.org/html/rfc3501#section-4.3).
3030
Validate(ValidateError),
3131
/// `native_tls` error
32-
NativeTlsError(native_tls::Error),
32+
NativeTlsError(async_native_tls::Error),
3333
/// Error appending an e-mail.
3434
Append,
3535
#[doc(hidden)]
@@ -54,8 +54,8 @@ impl<'a> From<&'a Response<'a>> for Error {
5454
}
5555
}
5656

57-
impl From<native_tls::Error> for Error {
58-
fn from(err: native_tls::Error) -> Error {
57+
impl From<async_native_tls::Error> for Error {
58+
fn from(err: async_native_tls::Error) -> Error {
5959
Error::NativeTlsError(err)
6060
}
6161
}

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
//!
2222
//! async fn fetch_inbox_top() -> Result<Option<String>> {
2323
//! let domain = "imap.example.com";
24-
//! let tls = native_tls::TlsConnector::builder().build().unwrap().into();
24+
//! let tls = async_native_tls::TlsConnector::new();
2525
//!
2626
//! // we pass in the domain twice to check that the server's TLS
2727
//! // certificate is valid for the domain we're connecting to.
28-
//! let client = async_imap::connect((domain, 993), domain, &tls).await?;
28+
//! let client = async_imap::connect((domain, 993), domain, tls).await?;
2929
//!
3030
//! // the client we have here is unauthenticated.
3131
//! // to do anything useful with the e-mails, we need to log in

tests/imap_integration.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,9 @@ impl rustls::ServerCertVerifier for NoCertificateVerification {
3030
}
3131

3232
fn tls() -> TlsConnector {
33-
native_tls::TlsConnector::builder()
33+
TlsConnector::new()
3434
.danger_accept_invalid_hostnames(true)
3535
.danger_accept_invalid_certs(true)
36-
.build()
37-
.unwrap()
38-
.into()
3936
}
4037

4138
async fn session(user: &str) -> Session<async_native_tls::TlsStream<TcpStream>> {
@@ -45,7 +42,7 @@ async fn session(user: &str) -> Session<async_native_tls::TlsStream<TcpStream>>
4542
std::env::var("TEST_HOST").unwrap_or("127.0.0.1".to_string())
4643
),
4744
"imap.example.com",
48-
&tls(),
45+
tls(),
4946
)
5047
.await
5148
.unwrap()
@@ -82,7 +79,7 @@ fn _connect_insecure_then_secure() {
8279

8380
// ignored because of https://github.com/greenmail-mail-test/greenmail/issues/135
8481
async_imap::Client::new(stream)
85-
.secure("imap.example.com", &tls())
82+
.secure("imap.example.com", tls())
8683
.await
8784
.unwrap();
8885
});
@@ -98,7 +95,7 @@ fn connect_secure() {
9895
std::env::var("TEST_HOST").unwrap_or("127.0.0.1".to_string())
9996
),
10097
"imap.example.com",
101-
&tls(),
98+
tls(),
10299
)
103100
.await
104101
.unwrap();

0 commit comments

Comments
 (0)