diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2022-06-13 18:01:07 +0200 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2022-06-13 18:01:07 +0200 |
commit | 12b379e7c3f832be5fd650ce3abc33b7d0b9fed8 (patch) | |
tree | d7c5e9dd63f54c90aae967fc0058d31b9deba120 /src/mailbox.rs | |
parent | 7113809cb7b9f0e73d942b295e693675301d1565 (diff) | |
download | aerogramme-12b379e7c3f832be5fd650ce3abc33b7d0b9fed8.tar.gz aerogramme-12b379e7c3f832be5fd650ce3abc33b7d0b9fed8.zip |
Handle select
Diffstat (limited to 'src/mailbox.rs')
-rw-r--r-- | src/mailbox.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/mailbox.rs b/src/mailbox.rs index af71b91..3b1ac99 100644 --- a/src/mailbox.rs +++ b/src/mailbox.rs @@ -8,6 +8,17 @@ use crate::cryptoblob::Key; use crate::login::Credentials; use crate::uidindex::*; +pub struct Summary { + pub validity: ImapUidvalidity, + pub next: ImapUid, + pub exists: usize, +} +impl std::fmt::Display for Summary { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "uidvalidity: {}, uidnext: {}, exists: {}", self.validity, self.next, self.exists) + } +} + pub struct Mailbox { bucket: String, pub name: String, @@ -33,6 +44,17 @@ impl Mailbox { }) } + pub async fn summary(&mut self) -> Result<Summary> { + self.uid_index.sync().await?; + let state = self.uid_index.state(); + + return Ok(Summary { + validity: state.uidvalidity, + next: state.uidnext, + exists: state.mail_uid.len(), + }) + } + pub async fn test(&mut self) -> Result<()> { self.uid_index.sync().await?; |