Skip to content

Commit 5898f9c

Browse files
committed
Parse MODSEQ from FETCH responses
1 parent bb73dfc commit 5898f9c

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

src/types/fetch.rs

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,31 +28,39 @@ pub struct Fetch {
2828
/// A number expressing the [RFC-2822](https://tools.ietf.org/html/rfc2822) size of the message.
2929
/// Only present if `RFC822.SIZE` was specified in the query argument to `FETCH`.
3030
pub size: Option<u32>,
31+
32+
/// A number expressing the [RFC-7162](https://tools.ietf.org/html/rfc7162) mod-sequence
33+
/// of the message.
34+
pub modseq: Option<u64>,
3135
}
3236

3337
impl Fetch {
3438
pub(crate) fn new(response: ResponseData) -> Self {
35-
let (message, uid, size) = if let Response::Fetch(message, attrs) = response.parsed() {
36-
let mut uid = None;
37-
let mut size = None;
38-
39-
for attr in attrs {
40-
match attr {
41-
AttributeValue::Uid(id) => uid = Some(*id),
42-
AttributeValue::Rfc822Size(sz) => size = Some(*sz),
43-
_ => {}
39+
let (message, uid, size, modseq) =
40+
if let Response::Fetch(message, attrs) = response.parsed() {
41+
let mut uid = None;
42+
let mut size = None;
43+
let mut modseq = None;
44+
45+
for attr in attrs {
46+
match attr {
47+
AttributeValue::Uid(id) => uid = Some(*id),
48+
AttributeValue::Rfc822Size(sz) => size = Some(*sz),
49+
AttributeValue::ModSeq(ms) => modseq = Some(*ms),
50+
_ => {}
51+
}
4452
}
45-
}
46-
(*message, uid, size)
47-
} else {
48-
unreachable!()
49-
};
53+
(*message, uid, size, modseq)
54+
} else {
55+
unreachable!()
56+
};
5057

5158
Fetch {
5259
response,
5360
message,
5461
uid,
5562
size,
63+
modseq,
5664
}
5765
}
5866

0 commit comments

Comments
 (0)