Implement list_mail() helper fn

This commit is contained in:
Matthias Beyer 2016-10-22 13:13:58 +02:00
parent d62a54ee74
commit e74c7392d9

View file

@ -93,7 +93,48 @@ fn list(rt: &Runtime) {
}; };
fn list_mail(m: Mail) { fn list_mail(m: Mail) {
unimplemented!() let id = match m.get_message_id() {
Ok(Some(f)) => f,
Ok(None) => "<no id>".to_owned(),
Err(e) => {
trace_error(&e);
"<error>".to_owned()
},
};
let from = match m.get_from() {
Ok(Some(f)) => f,
Ok(None) => "<no from>".to_owned(),
Err(e) => {
trace_error(&e);
"<error>".to_owned()
},
};
let to = match m.get_to() {
Ok(Some(f)) => f,
Ok(None) => "<no to>".to_owned(),
Err(e) => {
trace_error(&e);
"<error>".to_owned()
},
};
let subject = match m.get_subject() {
Ok(Some(f)) => f,
Ok(None) => "<no subject>".to_owned(),
Err(e) => {
trace_error(&e);
"<error>".to_owned()
},
};
println!("Mail: {id}\n\tFrom: {from}\n\tTo: {to}\n\t{subj}\n",
from = from,
id = id,
subj = subject,
to = to
);
} }
// TODO: Implement lister type in libimagmail for this // TODO: Implement lister type in libimagmail for this