Skip to content

Commit ad5df73

Browse files
authored
update imap proto to 1.14.3
1 parent 7cc85d0 commit ad5df73

File tree

9 files changed

+33
-37
lines changed

9 files changed

+33
-37
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ is-it-maintained-open-issues = { repository = "async-email/async-imap" }
2222
default = []
2323

2424
[dependencies]
25-
imap-proto = "0.11"
26-
nom = "5.0"
25+
imap-proto = "0.14.3"
26+
nom = "6.0"
2727
base64 = "0.13"
2828
chrono = "0.4"
2929
async-native-tls = { version = "0.3.3" }
3030
async-std = { version = "1.8.0", default-features = false, features = ["std"] }
3131
pin-utils = "0.1.0-alpha.4"
32-
futures = "0.3.0"
32+
futures = "0.3.15"
3333
rental = "0.5.5"
3434
stop-token = "0.2"
3535
byte-pool = "0.2.2"

src/client.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ impl<T: Read + Write + Unpin + fmt::Debug + Send> Client<T> {
318318
Response::Continue { information, .. } => {
319319
let challenge = if let Some(text) = information {
320320
ok_or_unauth_client_err!(
321-
base64::decode(text).map_err(|e| Error::Parse(
321+
base64::decode(text.as_ref()).map_err(|e| Error::Parse(
322322
ParseError::Authentication((*text).to_string(), Some(e))
323323
)),
324324
self
@@ -1347,7 +1347,7 @@ impl<T: Read + Write + Unpin + fmt::Debug> Connection<T> {
13471347
tag,
13481348
} = response.parsed()
13491349
{
1350-
self.check_status_ok(status, code.as_ref(), *information)?;
1350+
self.check_status_ok(status, code.as_ref(), information.as_deref())?;
13511351

13521352
if tag == id {
13531353
return Ok(());
@@ -1412,6 +1412,7 @@ mod tests {
14121412
use super::super::error::Result;
14131413
use super::super::mock_stream::MockStream;
14141414
use super::*;
1415+
use std::borrow::Cow;
14151416

14161417
use async_std::sync::{Arc, Mutex};
14171418
use imap_proto::Status;
@@ -1462,7 +1463,7 @@ mod tests {
14621463
&Response::Data {
14631464
status: Status::Ok,
14641465
code: None,
1465-
information: Some("Dovecot ready."),
1466+
information: Some(Cow::Borrowed("Dovecot ready.")),
14661467
}
14671468
);
14681469
}

src/extensions/idle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ impl<T: Read + Write + Unpin + fmt::Debug + Send> Handle<T> {
181181
if let Status::Bad = status {
182182
return Err(io::Error::new(
183183
io::ErrorKind::ConnectionRefused,
184-
information.unwrap().to_string(),
184+
information.as_ref().unwrap().to_string(),
185185
)
186186
.into());
187187
}

src/imap_stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl<R: Read + Write + Unpin> ImapStream<R> {
120120
}
121121
Err(nom::Err::Incomplete(Needed::Size(min))) => {
122122
log::trace!("decode: incomplete data, need minimum {} bytes", min);
123-
self.decode_needs = Some(min);
123+
self.decode_needs = Some(usize::from(min));
124124
Err(None)
125125
}
126126
Err(nom::Err::Incomplete(_)) => {

src/parse.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ pub(crate) async fn parse_mailbox<T: Stream<Item = io::Result<ResponseData>> + U
240240
MailboxDatum::MetadataSolicited { .. } => {}
241241
MailboxDatum::MetadataUnsolicited { .. } => {}
242242
MailboxDatum::Search { .. } => {}
243+
MailboxDatum::Sort { .. } => {}
244+
_ => {}
243245
},
244246
_ => {
245247
handle_unilateral(resp, unsolicited.clone()).await;
@@ -293,19 +295,8 @@ pub(crate) async fn handle_unilateral(
293295
Response::MailboxData(MailboxDatum::Status { mailbox, status }) => {
294296
unsolicited
295297
.send(UnsolicitedResponse::Status {
296-
mailbox: (*mailbox).into(),
297-
attributes: status
298-
.iter()
299-
.map(|s| match s {
300-
// Fake clone
301-
StatusAttribute::HighestModSeq(a) => StatusAttribute::HighestModSeq(*a),
302-
StatusAttribute::Messages(a) => StatusAttribute::Messages(*a),
303-
StatusAttribute::Recent(a) => StatusAttribute::Recent(*a),
304-
StatusAttribute::UidNext(a) => StatusAttribute::UidNext(*a),
305-
StatusAttribute::UidValidity(a) => StatusAttribute::UidValidity(*a),
306-
StatusAttribute::Unseen(a) => StatusAttribute::Unseen(*a),
307-
})
308-
.collect(),
298+
mailbox: (mailbox.as_ref()).into(),
299+
attributes: status.iter().cloned().collect(),
309300
})
310301
.await
311302
.expect("Channel closed unexpectedly");

src/types/capabilities.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ impl From<&CapabilityRef<'_>> for Capability {
2020
fn from(c: &CapabilityRef<'_>) -> Self {
2121
match c {
2222
CapabilityRef::Imap4rev1 => Capability::Imap4rev1,
23-
CapabilityRef::Auth(s) => Capability::Auth((*s).into()),
24-
CapabilityRef::Atom(s) => Capability::Atom((*s).into()),
23+
CapabilityRef::Auth(s) => Capability::Auth(s.clone().into_owned()),
24+
CapabilityRef::Atom(s) => Capability::Atom(s.clone().into_owned()),
2525
}
2626
}
2727
}

src/types/fetch.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl Fetch {
6363
.iter()
6464
.filter_map(|attr| match attr {
6565
AttributeValue::Flags(raw_flags) => {
66-
Some(raw_flags.iter().map(|s| Flag::from(*s)))
66+
Some(raw_flags.iter().map(|s| Flag::from(s.as_ref())))
6767
}
6868
_ => None,
6969
})
@@ -85,7 +85,7 @@ impl Fetch {
8585
data: Some(hdr),
8686
..
8787
}
88-
| AttributeValue::Rfc822Header(Some(hdr)) => Some(*hdr),
88+
| AttributeValue::Rfc822Header(Some(hdr)) => Some(hdr.as_ref()),
8989
_ => None,
9090
})
9191
.next()
@@ -107,7 +107,7 @@ impl Fetch {
107107
data: Some(body),
108108
..
109109
}
110-
| AttributeValue::Rfc822(Some(body)) => Some(*body),
110+
| AttributeValue::Rfc822(Some(body)) => Some(body.as_ref()),
111111
_ => None,
112112
})
113113
.next()
@@ -130,7 +130,7 @@ impl Fetch {
130130
data: Some(body),
131131
..
132132
}
133-
| AttributeValue::Rfc822Text(Some(body)) => Some(*body),
133+
| AttributeValue::Rfc822Text(Some(body)) => Some(body.as_ref()),
134134
_ => None,
135135
})
136136
.next()
@@ -173,7 +173,7 @@ impl Fetch {
173173
section: Some(sp),
174174
data: Some(data),
175175
..
176-
} if sp == path => Some(*data),
176+
} if sp == path => Some(data.as_ref()),
177177
_ => None,
178178
})
179179
.next()
@@ -191,7 +191,7 @@ impl Fetch {
191191
attrs
192192
.iter()
193193
.filter_map(|av| match av {
194-
AttributeValue::InternalDate(date_time) => Some(*date_time),
194+
AttributeValue::InternalDate(date_time) => Some(date_time.as_ref()),
195195
_ => None,
196196
})
197197
.next()

src/types/name.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,11 @@ impl Name {
9090
delimiter,
9191
name,
9292
}) => InnerName {
93-
attributes: flags.iter().map(|s| NameAttribute::from(*s)).collect(),
94-
delimiter: *delimiter,
93+
attributes: flags
94+
.iter()
95+
.map(|s| NameAttribute::from(s.as_ref()))
96+
.collect(),
97+
delimiter: delimiter.as_deref(),
9598
name,
9699
},
97100
_ => panic!("cannot construct from non mailbox data"),

tests/imap_integration.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::borrow::Cow;
12
use std::time::Duration;
23

34
use async_imap::Session;
@@ -171,17 +172,17 @@ fn inbox() {
171172
assert_ne!(fetch.uid, None);
172173
assert_eq!(fetch.size, Some(21));
173174
let e = fetch.envelope().unwrap();
174-
assert_eq!(e.subject, Some(&b"My first e-mail"[..]));
175+
assert_eq!(e.subject, Some(Cow::Borrowed(&b"My first e-mail"[..])));
175176
assert_ne!(e.from, None);
176177
assert_eq!(e.from.as_ref().unwrap().len(), 1);
177178
let from = &e.from.as_ref().unwrap()[0];
178-
assert_eq!(from.mailbox, Some(&b"sender"[..]));
179-
assert_eq!(from.host, Some(&b"localhost"[..]));
179+
assert_eq!(from.mailbox, Some(Cow::Borrowed(&b"sender"[..])));
180+
assert_eq!(from.host, Some(Cow::Borrowed(&b"localhost"[..])));
180181
assert_ne!(e.to, None);
181182
assert_eq!(e.to.as_ref().unwrap().len(), 1);
182183
let to = &e.to.as_ref().unwrap()[0];
183-
assert_eq!(to.mailbox, Some(&b"inbox"[..]));
184-
assert_eq!(to.host, Some(&b"localhost"[..]));
184+
assert_eq!(to.mailbox, Some(Cow::Borrowed(&b"inbox"[..])));
185+
assert_eq!(to.host, Some(Cow::Borrowed(&b"localhost"[..])));
185186
let date_opt = fetch.internal_date();
186187
assert!(date_opt.is_some());
187188

@@ -247,7 +248,7 @@ fn inbox_uid() {
247248
let fetch = &fetch[0];
248249
assert_eq!(fetch.uid, Some(uid));
249250
let e = fetch.envelope().unwrap();
250-
assert_eq!(e.subject, Some(&b"My first e-mail"[..]));
251+
assert_eq!(e.subject, Some(Cow::Borrowed(&b"My first e-mail"[..])));
251252
let date_opt = fetch.internal_date();
252253
assert!(date_opt.is_some());
253254

0 commit comments

Comments
 (0)