melib: add clear debug prints in email structs
parent
b0097574a5
commit
2f3c168aeb
|
@ -61,7 +61,7 @@ pub struct MailboxAddress {
|
||||||
address_spec: StrBuilder,
|
address_spec: StrBuilder,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Serialize, Deserialize)]
|
||||||
pub enum Address {
|
pub enum Address {
|
||||||
Mailbox(MailboxAddress),
|
Mailbox(MailboxAddress),
|
||||||
Group(GroupAddress),
|
Group(GroupAddress),
|
||||||
|
@ -78,11 +78,11 @@ impl PartialEq for Address {
|
||||||
s.address_spec.display(&s.raw) == o.address_spec.display(&o.raw)
|
s.address_spec.display(&s.raw) == o.address_spec.display(&o.raw)
|
||||||
}
|
}
|
||||||
(Address::Group(s), Address::Group(o)) => {
|
(Address::Group(s), Address::Group(o)) => {
|
||||||
s.display_name.display(&s.raw) == o.display_name.display(&o.raw)
|
s.display_name.display(&s.raw) == o.display_name.display(&o.raw) && s
|
||||||
&& s.mailbox_list
|
.mailbox_list
|
||||||
.iter()
|
.iter()
|
||||||
.zip(o.mailbox_list.iter())
|
.zip(o.mailbox_list.iter())
|
||||||
.fold(true, |b, (s, o)| b && (s == o))
|
.fold(true, |b, (s, o)| b && (s == o))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,6 +112,12 @@ impl fmt::Display for Address {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for Address {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
fmt::Display::fmt(self, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Helper struct to return slices from a struct field on demand.
|
/// Helper struct to return slices from a struct field on demand.
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize, Default)]
|
#[derive(Clone, Debug, Serialize, Deserialize, Default)]
|
||||||
struct StrBuilder {
|
struct StrBuilder {
|
||||||
|
@ -270,7 +276,7 @@ pub type EnvelopeHash = u64;
|
||||||
/// Access to the underlying email object in the account's backend (for example the file or the
|
/// Access to the underlying email object in the account's backend (for example the file or the
|
||||||
/// entry in an IMAP server) is given through `operation_token`. For more information see
|
/// entry in an IMAP server) is given through `operation_token`. For more information see
|
||||||
/// `BackendOp`.
|
/// `BackendOp`.
|
||||||
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
#[derive(Clone, Default, Serialize, Deserialize)]
|
||||||
pub struct Envelope {
|
pub struct Envelope {
|
||||||
date: String,
|
date: String,
|
||||||
from: Vec<Address>,
|
from: Vec<Address>,
|
||||||
|
@ -290,6 +296,19 @@ pub struct Envelope {
|
||||||
flags: Flag,
|
flags: Flag,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for Envelope {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
write!(f, "Envelope {{\ndate: {}\n,from:{:#?}\nto {:#?}\nmessage_id: {},\n references: {:#?}\nhash: {}\n
|
||||||
|
}}",
|
||||||
|
self.date,
|
||||||
|
self.from,
|
||||||
|
self.to,
|
||||||
|
self.message_id_display(),
|
||||||
|
self.references,
|
||||||
|
self.hash)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Envelope {
|
impl Envelope {
|
||||||
pub fn new(hash: EnvelopeHash) -> Self {
|
pub fn new(hash: EnvelopeHash) -> Self {
|
||||||
Envelope {
|
Envelope {
|
||||||
|
|
|
@ -43,6 +43,7 @@ use std::option::Option;
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Mailbox {
|
pub struct Mailbox {
|
||||||
pub folder: Folder,
|
pub folder: Folder,
|
||||||
|
name: String,
|
||||||
pub collection: Collection,
|
pub collection: Collection,
|
||||||
has_sent: bool,
|
has_sent: bool,
|
||||||
}
|
}
|
||||||
|
@ -53,6 +54,7 @@ impl Clone for Mailbox {
|
||||||
folder: self.folder.clone(),
|
folder: self.folder.clone(),
|
||||||
collection: self.collection.clone(),
|
collection: self.collection.clone(),
|
||||||
has_sent: self.has_sent,
|
has_sent: self.has_sent,
|
||||||
|
name: self.name.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,6 +64,7 @@ impl Default for Mailbox {
|
||||||
folder: folder_default(),
|
folder: folder_default(),
|
||||||
collection: Collection::default(),
|
collection: Collection::default(),
|
||||||
has_sent: false,
|
has_sent: false,
|
||||||
|
name: String::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,12 +74,19 @@ impl Mailbox {
|
||||||
let mut envelopes: Vec<Envelope> = envelopes?;
|
let mut envelopes: Vec<Envelope> = envelopes?;
|
||||||
envelopes.sort_by(|a, b| a.date().cmp(&b.date()));
|
envelopes.sort_by(|a, b| a.date().cmp(&b.date()));
|
||||||
let collection = Collection::new(envelopes, &folder);
|
let collection = Collection::new(envelopes, &folder);
|
||||||
|
let name = folder.name().into();
|
||||||
Ok(Mailbox {
|
Ok(Mailbox {
|
||||||
folder,
|
folder,
|
||||||
collection,
|
collection,
|
||||||
|
name: name,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn name(&self) -> &str {
|
||||||
|
&self.name
|
||||||
|
}
|
||||||
|
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
self.collection.is_empty()
|
self.collection.is_empty()
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ use self::fnv::{FnvHashMap, FnvHashSet};
|
||||||
use std::cell::{Ref, RefCell};
|
use std::cell::{Ref, RefCell};
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
|
use std::fmt;
|
||||||
use std::iter::FromIterator;
|
use std::iter::FromIterator;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::ops::Index;
|
use std::ops::Index;
|
||||||
|
@ -199,12 +200,18 @@ impl FromStr for SortOrder {
|
||||||
/*
|
/*
|
||||||
* The thread tree holds the sorted state of the thread nodes */
|
* The thread tree holds the sorted state of the thread nodes */
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Deserialize, Serialize)]
|
||||||
struct ThreadTree {
|
struct ThreadTree {
|
||||||
id: usize,
|
id: usize,
|
||||||
children: Vec<ThreadTree>,
|
children: Vec<ThreadTree>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for ThreadTree {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
write!(f, "")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl ThreadTree {
|
impl ThreadTree {
|
||||||
fn new(id: usize) -> Self {
|
fn new(id: usize) -> Self {
|
||||||
ThreadTree {
|
ThreadTree {
|
||||||
|
|
Loading…
Reference in New Issue