aboutsummaryrefslogtreecommitdiff
path: root/src/mail/snapshot.rs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-05-29 10:14:51 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-05-29 10:14:51 +0200
commitb9ce5886033677f6c65a4b873e17574fdb8df31d (patch)
tree9ed1d721361027d7d6fef0ecad65d7e1b74a7ddb /src/mail/snapshot.rs
parent0dcf69f180f5a7b71b6ad2ac67e4cdd81e5154f1 (diff)
parent5954de6efbb040b8b47daf0c7663a60f3db1da6e (diff)
downloadaerogramme-b9ce5886033677f6c65a4b873e17574fdb8df31d.tar.gz
aerogramme-b9ce5886033677f6c65a4b873e17574fdb8df31d.zip
Merge branch 'caldav'
Diffstat (limited to 'src/mail/snapshot.rs')
-rw-r--r--src/mail/snapshot.rs60
1 files changed, 0 insertions, 60 deletions
diff --git a/src/mail/snapshot.rs b/src/mail/snapshot.rs
deleted file mode 100644
index ed756b5..0000000
--- a/src/mail/snapshot.rs
+++ /dev/null
@@ -1,60 +0,0 @@
-use std::sync::Arc;
-
-use anyhow::Result;
-
-use super::mailbox::Mailbox;
-use super::query::{Query, QueryScope};
-use super::uidindex::UidIndex;
-use super::unique_ident::UniqueIdent;
-
-/// A Frozen Mailbox has a snapshot of the current mailbox
-/// state that is desynchronized with the real mailbox state.
-/// It's up to the user to choose when their snapshot must be updated
-/// to give useful information to their clients
-pub struct FrozenMailbox {
- pub mailbox: Arc<Mailbox>,
- pub snapshot: UidIndex,
-}
-
-impl FrozenMailbox {
- /// Create a snapshot from a mailbox, the mailbox + the snapshot
- /// becomes the "Frozen Mailbox".
- pub async fn new(mailbox: Arc<Mailbox>) -> Self {
- let state = mailbox.current_uid_index().await;
-
- Self {
- mailbox,
- snapshot: state,
- }
- }
-
- /// Force the synchronization of the inner mailbox
- /// but do not update the local snapshot
- pub async fn sync(&self) -> Result<()> {
- self.mailbox.opportunistic_sync().await
- }
-
- /// Peek snapshot without updating the frozen mailbox
- /// Can be useful if you want to plan some writes
- /// while sending a diff to the client later
- pub async fn peek(&self) -> UidIndex {
- self.mailbox.current_uid_index().await
- }
-
- /// Update the FrozenMailbox local snapshot.
- /// Returns the old snapshot, so you can build a diff
- pub async fn update(&mut self) -> UidIndex {
- let old_snapshot = self.snapshot.clone();
- self.snapshot = self.mailbox.current_uid_index().await;
-
- old_snapshot
- }
-
- pub fn query<'a, 'b>(&'a self, uuids: &'b [UniqueIdent], scope: QueryScope) -> Query<'a, 'b> {
- Query {
- frozen: self,
- emails: uuids,
- scope,
- }
- }
-}