From 4ea652e3f79da8d913d38fd031751d48e8891444 Mon Sep 17 00:00:00 2001 From: Conrad Hoffmann Date: Thu, 14 Jul 2022 10:19:00 +0200 Subject: [PATCH] Expose MODSEQ attribute in FETCH responses If the QRESYNC (RFC 7162) extension is being used, a FETCH response to a STORE or UID STORE command with the UNCHANGEDSINCE query attribute will return the mod sequence ID of the performed operation. This information is crucial for building efficient caching clients. --- src/types/fetch.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/types/fetch.rs b/src/types/fetch.rs index 417da00..c64e71a 100644 --- a/src/types/fetch.rs +++ b/src/types/fetch.rs @@ -115,6 +115,17 @@ impl<'a> Fetch<'a> { &self.flags[..] } + /// Contains the mod sequence of the performed operation if in response to a `STORE` or + /// `UID STORE` with `UNCHANGEDSINCE` in the query arguments. + /// `UNCHANGEDSINCE` and the inclusion of the mod sequence in the response are part of the + /// [QRESYNC](https://tools.ietf.org/html/rfc7162#section-3.1.3) extension. + pub fn mod_seq(&self) -> Option { + self.fetch.iter().find_map(|av| match av { + AttributeValue::ModSeq(mod_seq) => Some(*mod_seq), + _ => None, + }) + } + /// The bytes that make up the header of this message, if `BODY[HEADER]`, `BODY.PEEK[HEADER]`, /// or `RFC822.HEADER` was included in the `query` argument to `FETCH`. pub fn header(&self) -> Option<&[u8]> {