From 36bbc2138bceb0c80a306f8c225e340d6fbd5470 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Tue, 28 Jun 2022 10:49:28 +0200 Subject: cargo fmt + implement noop --- src/mail/mod.rs | 47 ++++++++++++++++++++++++++++++++++++++++++----- src/mail/uidindex.rs | 2 +- 2 files changed, 43 insertions(+), 6 deletions(-) (limited to 'src/mail') diff --git a/src/mail/mod.rs b/src/mail/mod.rs index 2edcaa7..7c62c59 100644 --- a/src/mail/mod.rs +++ b/src/mail/mod.rs @@ -13,6 +13,10 @@ use crate::login::Credentials; use crate::mail::mail_ident::*; use crate::mail::uidindex::*; +// Internet Message Format +// aka RFC 822 - RFC 2822 - RFC 5322 +pub struct IMF(Vec); + pub struct Summary<'a> { pub validity: ImapUidvalidity, pub next: ImapUid, @@ -31,7 +35,6 @@ impl std::fmt::Display for Summary<'_> { } } - // Non standard but common flags: // https://www.iana.org/assignments/imap-jmap-keywords/imap-jmap-keywords.xhtml pub struct Mailbox { @@ -45,8 +48,6 @@ pub struct Mailbox { uid_index: Bayou, } -// IDEA: We store a specific flag named $unseen. -// If it is not present, we add the virtual flag \Seen impl Mailbox { pub fn new(creds: &Credentials, name: String) -> Result { let uid_index = Bayou::::new(creds, name.clone())?; @@ -61,12 +62,20 @@ impl Mailbox { }) } + // Get a summary of the mailbox, useful for the SELECT command for example pub async fn summary(&mut self) -> Result { self.uid_index.sync().await?; let state = self.uid_index.state(); - let unseen = state.idx_by_flag.get(&"$unseen".to_string()).and_then(|os| os.get_min()); - let recent = state.idx_by_flag.get(&"\\Recent".to_string()).map(|os| os.len()).unwrap_or(0); + let unseen = state + .idx_by_flag + .get(&"$unseen".to_string()) + .and_then(|os| os.get_min()); + let recent = state + .idx_by_flag + .get(&"\\Recent".to_string()) + .map(|os| os.len()) + .unwrap_or(0); return Ok(Summary { validity: state.uidvalidity, @@ -78,6 +87,34 @@ impl Mailbox { }); } + // Insert an email in the mailbox + pub async fn append(&mut self, msg: IMF) -> Result<()> { + Ok(()) + } + + // Copy an email from an external to this mailbox + // @FIXME is it needed or could we implement it with append? + pub async fn copy(&mut self, mailbox: String, uid: ImapUid) -> Result<()> { + Ok(()) + } + + // Delete all emails with the \Delete flag in the mailbox + // Can be called by CLOSE and EXPUNGE + // @FIXME do we want to implement this feature or a simpler "delete" command + // The controller could then "fetch \Delete" and call delete on each email? + pub async fn expunge(&mut self) -> Result<()> { + Ok(()) + } + + // Update flags of a range of emails + pub async fn store(&mut self) -> Result<()> { + Ok(()) + } + + pub async fn fetch(&mut self) -> Result<()> { + Ok(()) + } + pub async fn test(&mut self) -> Result<()> { self.uid_index.sync().await?; diff --git a/src/mail/uidindex.rs b/src/mail/uidindex.rs index 49dbba5..ad27c1b 100644 --- a/src/mail/uidindex.rs +++ b/src/mail/uidindex.rs @@ -186,7 +186,7 @@ impl FlagIndex { pub fn get(&self, f: &Flag) -> Option<&OrdSet> { self.0.get(f) - } + } pub fn flags(&self) -> FlagIter { self.0.keys() -- cgit v1.2.3