imap_proto/parser/rfc4551.rs
1//!
2//! https://tools.ietf.org/html/rfc4551
3//!
4//! IMAP Extension for Conditional STORE Operation
5//! or Quick Flag Changes Resynchronization
6//!
7
8use nom::{bytes::streaming::tag_no_case, sequence::tuple, IResult};
9
10use crate::{
11 parser::core::{number_64, paren_delimited},
12 types::*,
13};
14
15// The highest mod-sequence value of all messages in the mailbox.
16// Extends resp-test-code defined in rfc3501.
17// [RFC4551 - 3.6 HIGHESTMODSEQ Status Data Items](https://tools.ietf.org/html/rfc4551#section-3.6)
18// [RFC4551 - 4. Formal Syntax - resp-text-code](https://tools.ietf.org/html/rfc4551#section-4)
19pub(crate) fn resp_text_code_highest_mod_seq(i: &[u8]) -> IResult<&[u8], ResponseCode<'_>> {
20 let (i, (_, num)) = tuple((tag_no_case("HIGHESTMODSEQ "), number_64))(i)?;
21 Ok((i, ResponseCode::HighestModSeq(num)))
22}
23
24// Extends status-att/status-att-list defined in rfc3501
25// [RFC4551 - 3.6 - HIGHESTMODSEQ Status Data Items](https://tools.ietf.org/html/rfc4551#section-3.6)
26// [RFC4551 - 4. Formal Syntax - status-att-val](https://tools.ietf.org/html/rfc4551#section-4)
27pub(crate) fn status_att_val_highest_mod_seq(i: &[u8]) -> IResult<&[u8], StatusAttribute> {
28 let (i, (_, num)) = tuple((tag_no_case("HIGHESTMODSEQ "), number_64))(i)?;
29 Ok((i, StatusAttribute::HighestModSeq(num)))
30}
31
32// [RFC4551 - 4. Formal Syntax - fetch-mod-resp](https://tools.ietf.org/html/rfc4551#section-4)
33pub(crate) fn msg_att_mod_seq(i: &[u8]) -> IResult<&[u8], AttributeValue<'_>> {
34 let (i, (_, num)) = tuple((tag_no_case("MODSEQ "), paren_delimited(number_64)))(i)?;
35 Ok((i, AttributeValue::ModSeq(num)))
36}