mirror of
https://github.com/pimalaya/himalaya.git
synced 2026-06-17 13:17:55 +08:00
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:
+1
-1
@@ -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
@@ -1,2 +1,4 @@
|
||||
pub mod account;
|
||||
mod process;
|
||||
|
||||
pub mod account;
|
||||
pub mod mbox;
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
mod mbox;
|
||||
pub use mbox::*;
|
||||
|
||||
mod mboxes;
|
||||
pub use mboxes::*;
|
||||
Reference in New Issue
Block a user