aboutsummaryrefslogtreecommitdiff
path: root/src/mail
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2022-06-28 10:49:28 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2022-06-28 10:49:28 +0200
commit36bbc2138bceb0c80a306f8c225e340d6fbd5470 (patch)
tree9592daf96a58a61b16337968b662e85199e0e158 /src/mail
parent927b461f25e8202a33fadc1f823d4feed6282f60 (diff)
downloadaerogramme-36bbc2138bceb0c80a306f8c225e340d6fbd5470.tar.gz
aerogramme-36bbc2138bceb0c80a306f8c225e340d6fbd5470.zip
cargo fmt + implement noop
Diffstat (limited to 'src/mail')
-rw-r--r--src/mail/mod.rs47
-rw-r--r--src/mail/uidindex.rs2
2 files changed, 43 insertions, 6 deletions
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<u8>);
+
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<UidIndex>,
}
-// 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<Self> {
let uid_index = Bayou::<UidIndex>::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<Summary> {
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<ImapUid>> {
self.0.get(f)
- }
+ }
pub fn flags(&self) -> FlagIter {
self.0.keys()