make Backend::get_mboxes return struct instead of trait (#340)

This step was necessary to move logic from CLI to lib. Indeed, the
trait returned by get_mboxes needed to implement Table, which is
related to the CLI module only.
This commit is contained in:
Clément DOUIN
2022-05-29 12:36:10 +02:00
parent a0461d84ba
commit 7c01f88006
20 changed files with 193 additions and 575 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ edition = "2021"
imap-backend = ["imap", "imap-proto"]
maildir-backend = ["maildir", "md5"]
notmuch-backend = ["notmuch", "maildir-backend"]
default = ["imap-backend", "maildir-backend"]
default = ["imap-backend", "maildir-backend", "notmuch-backend"]
[dependencies]
lettre = { version = "0.10.0-rc.1", features = ["serde"] }
+3 -1
View File
@@ -1,2 +1,4 @@
pub mod account;
mod process;
pub mod account;
pub mod mbox;
+19
View File
@@ -0,0 +1,19 @@
use serde::Serialize;
use std::fmt;
/// Represents the mailbox.
#[derive(Debug, Default, PartialEq, Eq, Serialize)]
pub struct Mbox {
/// Represents the mailbox hierarchie delimiter.
pub delim: String,
/// Represents the mailbox name.
pub name: String,
/// Represents the mailbox description.
pub desc: String,
}
impl fmt::Display for Mbox {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.name)
}
}
+25
View File
@@ -0,0 +1,25 @@
use serde::Serialize;
use std::ops::{Deref, DerefMut};
use super::Mbox;
/// Represents the list of mailboxes.
#[derive(Debug, Default, Serialize)]
pub struct Mboxes {
#[serde(rename = "response")]
pub mboxes: Vec<Mbox>,
}
impl Deref for Mboxes {
type Target = Vec<Mbox>;
fn deref(&self) -> &Self::Target {
&self.mboxes
}
}
impl DerefMut for Mboxes {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.mboxes
}
}
+5
View File
@@ -0,0 +1,5 @@
mod mbox;
pub use mbox::*;
mod mboxes;
pub use mboxes::*;