aboutsummaryrefslogtreecommitdiff
path: root/src/imap/index.rs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-01-11 23:02:03 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-01-11 23:02:03 +0100
commit3c7186ab5ac5a66f782a038d937b6679780df458 (patch)
treeee83fb3040ef077d36d807b0134c3141a0ea1d01 /src/imap/index.rs
parentd24eb9918e3ab0c69af05c8cb92424ecaba903f3 (diff)
downloadaerogramme-3c7186ab5ac5a66f782a038d937b6679780df458.tar.gz
aerogramme-3c7186ab5ac5a66f782a038d937b6679780df458.zip
Finalize implementation of CONDSTORE
Diffstat (limited to 'src/imap/index.rs')
-rw-r--r--src/imap/index.rs32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/imap/index.rs b/src/imap/index.rs
index 44109d5..9b794b8 100644
--- a/src/imap/index.rs
+++ b/src/imap/index.rs
@@ -1,4 +1,4 @@
-use std::num::NonZeroU32;
+use std::num::{NonZeroU32, NonZeroU64};
use anyhow::{anyhow, Result};
use imap_codec::imap_types::sequence::{SeqOrUid, Sequence, SequenceSet};
@@ -126,6 +126,36 @@ impl<'a> Index<'a> {
_ => self.fetch_on_id(sequence_set),
}
}
+
+ pub fn fetch_changed_since(
+ self: &'a Index<'a>,
+ sequence_set: &SequenceSet,
+ maybe_modseq: Option<NonZeroU64>,
+ by_uid: bool,
+ ) -> Result<Vec<&'a MailIndex<'a>>> {
+ let raw = self.fetch(sequence_set, by_uid)?;
+ let res = match maybe_modseq {
+ Some(pit) => raw.into_iter().filter(|midx| midx.modseq > pit).collect(),
+ None => raw,
+ };
+
+ Ok(res)
+ }
+
+ pub fn fetch_unchanged_since(
+ self: &'a Index<'a>,
+ sequence_set: &SequenceSet,
+ maybe_modseq: Option<NonZeroU64>,
+ by_uid: bool,
+ ) -> Result<(Vec<&'a MailIndex<'a>>, Vec<&'a MailIndex<'a>>)> {
+ let raw = self.fetch(sequence_set, by_uid)?;
+ let res = match maybe_modseq {
+ Some(pit) => raw.into_iter().partition(|midx| midx.modseq <= pit),
+ None => (raw, vec![]),
+ };
+
+ Ok(res)
+ }
}
#[derive(Clone, Debug)]