aboutsummaryrefslogtreecommitdiff
path: root/src/mail
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-06-29 13:41:05 +0200
committerAlex Auvolat <alex@adnab.me>2022-06-29 13:41:05 +0200
commit8b7eb1ca918d26901b0739526341128067ca1cbc (patch)
tree9bd9d8d4248f43a4f9dfaff7e5b83296f771463d /src/mail
parent1bc109df72a3d785211a128b3f28746232258924 (diff)
downloadaerogramme-8b7eb1ca918d26901b0739526341128067ca1cbc.tar.gz
aerogramme-8b7eb1ca918d26901b0739526341128067ca1cbc.zip
work on prototypes
Diffstat (limited to 'src/mail')
-rw-r--r--src/mail/mailbox.rs37
-rw-r--r--src/mail/mod.rs2
-rw-r--r--src/mail/user.rs25
3 files changed, 44 insertions, 20 deletions
diff --git a/src/mail/mailbox.rs b/src/mail/mailbox.rs
index e19dfd8..a2d28fb 100644
--- a/src/mail/mailbox.rs
+++ b/src/mail/mailbox.rs
@@ -19,6 +19,7 @@ pub struct Summary<'a> {
pub flags: FlagIter<'a>,
pub unseen: Option<&'a ImapUid>,
}
+
impl std::fmt::Display for Summary<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(
@@ -44,14 +45,14 @@ pub struct Mailbox {
}
impl Mailbox {
- pub(super) fn new(creds: &Credentials, name: String) -> Result<Self> {
+ pub(super) fn new(creds: &Credentials, name: &str) -> Result<Self> {
let index_path = format!("index/{}", name);
let mail_path = format!("mail/{}", name);
let uid_index = Bayou::<UidIndex>::new(creds, index_path)?;
Ok(Self {
bucket: creds.bucket().to_string(),
- name,
+ name: name.to_string(), // TODO: don't use name field if possible, use mail_path instead
key: creds.keys.master.clone(),
k2v: creds.k2v_client()?,
s3: creds.s3_client()?,
@@ -60,7 +61,7 @@ impl Mailbox {
})
}
- // Get a summary of the mailbox, useful for the SELECT command for example
+ /// 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();
@@ -85,34 +86,36 @@ impl Mailbox {
});
}
- // Insert an email in the mailbox
+ /// Insert an email in the mailbox
pub async fn append(&mut self, _msg: IMF) -> Result<()> {
- Ok(())
+ unimplemented!()
}
- // 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(())
+ /// Copy an email from an other Mailbox to this mailbox
+ /// (use this when possible, as it allows for a certain number of storage optimizations)
+ pub async fn copy(&mut self, _from: &Mailbox, _uid: ImapUid) -> Result<()> {
+ unimplemented!()
}
- // 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?
+ /// 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(())
+ unimplemented!()
}
- // Update flags of a range of emails
+ /// Update flags of a range of emails
pub async fn store(&mut self) -> Result<()> {
- Ok(())
+ unimplemented!()
}
pub async fn fetch(&mut self) -> Result<()> {
- Ok(())
+ unimplemented!()
}
+ // ----
+
pub async fn test(&mut self) -> Result<()> {
self.uid_index.sync().await?;
diff --git a/src/mail/mod.rs b/src/mail/mod.rs
index f696f6d..4339038 100644
--- a/src/mail/mod.rs
+++ b/src/mail/mod.rs
@@ -1,7 +1,7 @@
pub mod mail_ident;
-pub mod user;
pub mod mailbox;
mod uidindex;
+pub mod user;
use std::convert::TryFrom;
diff --git a/src/mail/user.rs b/src/mail/user.rs
index 7465ab0..4864509 100644
--- a/src/mail/user.rs
+++ b/src/mail/user.rs
@@ -25,7 +25,28 @@ impl User {
})
}
- pub fn open_mailbox(&self, name: String) -> Result<Mailbox> {
- Mailbox::new(&self.creds, name)
+ /// Lists user's available mailboxes
+ pub fn list_mailboxes(&self) -> Result<Vec<String>> {
+ unimplemented!()
+ }
+
+ /// Opens an existing mailbox given its IMAP name.
+ pub fn open_mailbox(&self, name: &str) -> Result<Option<Mailbox>> {
+ Mailbox::new(&self.creds, name).map(Some)
+ }
+
+ /// Creates a new mailbox in the user's IMAP namespace.
+ pub fn create_mailbox(&self, name: &str) -> Result<()> {
+ unimplemented!()
+ }
+
+ /// Deletes a mailbox in the user's IMAP namespace.
+ pub fn delete_mailbox(&self, name: &str) -> Result<()> {
+ unimplemented!()
+ }
+
+ /// Renames a mailbox in the user's IMAP namespace.
+ pub fn rename_mailbox(&self, old_name: &str, new_name: &str) -> Result<()> {
+ unimplemented!()
}
}