aboutsummaryrefslogtreecommitdiff
path: root/src/mailbox.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailbox.rs')
-rw-r--r--src/mailbox.rs22
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?;