aboutsummaryrefslogtreecommitdiff
path: root/src/mail
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-07-12 15:59:13 +0200
committerAlex Auvolat <alex@adnab.me>2022-07-12 15:59:13 +0200
commit9b7d999fd52dc3410b97ca831238b084650be1b3 (patch)
tree34b78838be9e13a41f04c17b57ac3a1f5311b3a9 /src/mail
parentfc2e25ce76c20a4d2e8316317c7303ae8d78b031 (diff)
downloadaerogramme-9b7d999fd52dc3410b97ca831238b084650be1b3.tar.gz
aerogramme-9b7d999fd52dc3410b97ca831238b084650be1b3.zip
Implement STATUS
Diffstat (limited to 'src/mail')
-rw-r--r--src/mail/unique_ident.rs8
-rw-r--r--src/mail/user.rs11
2 files changed, 17 insertions, 2 deletions
diff --git a/src/mail/unique_ident.rs b/src/mail/unique_ident.rs
index 19de6fc..267f66e 100644
--- a/src/mail/unique_ident.rs
+++ b/src/mail/unique_ident.rs
@@ -16,7 +16,7 @@ use crate::time::now_msec;
/// required by Aerogramme.
/// Their main property is to be unique without having to rely
/// on synchronization between IMAP processes.
-#[derive(Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash, Debug)]
+#[derive(Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)]
pub struct UniqueIdent(pub [u8; 24]);
struct IdentGenerator {
@@ -78,6 +78,12 @@ impl std::fmt::Display for UniqueIdent {
}
}
+impl std::fmt::Debug for UniqueIdent {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(f, "{}", hex::encode(self.0))
+ }
+}
+
impl FromStr for UniqueIdent {
type Err = &'static str;
diff --git a/src/mail/user.rs b/src/mail/user.rs
index e80931f..fd858d3 100644
--- a/src/mail/user.rs
+++ b/src/mail/user.rs
@@ -71,7 +71,10 @@ impl User {
/// Opens an existing mailbox given its IMAP name.
pub async fn open_mailbox(&self, name: &str) -> Result<Option<Arc<Mailbox>>> {
let (mut list, ct) = self.load_mailbox_list().await?;
- eprintln!("List of mailboxes: {:?}", &list.0);
+ eprintln!("List of mailboxes:");
+ for ent in list.0.iter() {
+ eprintln!(" - {:?}", ent);
+ }
if let Some((uidvalidity, Some(mbid))) = list.get_mailbox(name) {
let mb_opt = self.open_mailbox_by_id(mbid, uidvalidity).await?;
@@ -88,6 +91,12 @@ impl User {
}
}
+ /// Check whether mailbox exists
+ pub async fn has_mailbox(&self, name: &str) -> Result<bool> {
+ let (list, _ct) = self.load_mailbox_list().await?;
+ Ok(list.has_mailbox(name))
+ }
+
/// Creates a new mailbox in the user's IMAP namespace.
pub async fn create_mailbox(&self, name: &str) -> Result<()> {
if name.ends_with(MAILBOX_HIERARCHY_DELIMITER) {