mirror of
https://github.com/soywod/himalaya.git
synced 2024-07-05 17:15:12 +00:00
make Backend::add_msg return String instead of trait (#340)
This step was necessary to move logic from CLI to lib.
This commit is contained in:
parent
7c01f88006
commit
e1c92d3f57
|
@ -30,7 +30,7 @@ pub trait Backend<'a> {
|
|||
page_size: usize,
|
||||
page: usize,
|
||||
) -> Result<Box<dyn Envelopes>>;
|
||||
fn add_msg(&mut self, mbox: &str, msg: &[u8], flags: &str) -> Result<Box<dyn ToString>>;
|
||||
fn add_msg(&mut self, mbox: &str, msg: &[u8], flags: &str) -> Result<String>;
|
||||
fn get_msg(&mut self, mbox: &str, id: &str) -> Result<Msg>;
|
||||
fn copy_msg(&mut self, mbox_src: &str, mbox_dst: &str, ids: &str) -> Result<()>;
|
||||
fn move_msg(&mut self, mbox_src: &str, mbox_dst: &str, ids: &str) -> Result<()>;
|
||||
|
|
|
@ -342,7 +342,7 @@ impl<'a> Backend<'a> for ImapBackend<'a> {
|
|||
Ok(Box::new(envelopes))
|
||||
}
|
||||
|
||||
fn add_msg(&mut self, mbox: &str, msg: &[u8], flags: &str) -> Result<Box<dyn ToString>> {
|
||||
fn add_msg(&mut self, mbox: &str, msg: &[u8], flags: &str) -> Result<String> {
|
||||
let flags: ImapFlags = flags.into();
|
||||
self.sess()?
|
||||
.append(mbox, msg)
|
||||
|
@ -354,7 +354,7 @@ impl<'a> Backend<'a> for ImapBackend<'a> {
|
|||
.select(mbox)
|
||||
.context(format!("cannot select mailbox {:?}", mbox))?
|
||||
.exists;
|
||||
Ok(Box::new(last_seq))
|
||||
Ok(last_seq.to_string())
|
||||
}
|
||||
|
||||
fn get_msg(&mut self, mbox: &str, seq: &str) -> Result<Msg> {
|
||||
|
|
|
@ -215,7 +215,7 @@ impl<'a> Backend<'a> for MaildirBackend<'a> {
|
|||
))
|
||||
}
|
||||
|
||||
fn add_msg(&mut self, dir: &str, msg: &[u8], flags: &str) -> Result<Box<dyn ToString>> {
|
||||
fn add_msg(&mut self, dir: &str, msg: &[u8], flags: &str) -> Result<String> {
|
||||
info!(">> add maildir message");
|
||||
debug!("dir: {:?}", dir);
|
||||
debug!("flags: {:?}", flags);
|
||||
|
@ -246,7 +246,7 @@ impl<'a> Backend<'a> for MaildirBackend<'a> {
|
|||
})?;
|
||||
|
||||
info!("<< add maildir message");
|
||||
Ok(Box::new(hash))
|
||||
Ok(hash)
|
||||
}
|
||||
|
||||
fn get_msg(&mut self, dir: &str, short_hash: &str) -> Result<Msg> {
|
||||
|
|
|
@ -197,7 +197,7 @@ impl<'a> Backend<'a> for NotmuchBackend<'a> {
|
|||
Ok(envelopes)
|
||||
}
|
||||
|
||||
fn add_msg(&mut self, _: &str, msg: &[u8], tags: &str) -> Result<Box<dyn ToString>> {
|
||||
fn add_msg(&mut self, _: &str, msg: &[u8], tags: &str) -> Result<String> {
|
||||
info!(">> add notmuch envelopes");
|
||||
debug!("tags: {:?}", tags);
|
||||
|
||||
|
@ -251,7 +251,7 @@ impl<'a> Backend<'a> for NotmuchBackend<'a> {
|
|||
.with_context(|| format!("cannot add flags to notmuch message {:?}", id))?;
|
||||
|
||||
info!("<< add notmuch envelopes");
|
||||
Ok(Box::new(hash))
|
||||
Ok(hash)
|
||||
}
|
||||
|
||||
fn get_msg(&mut self, _: &str, short_hash: &str) -> Result<Msg> {
|
||||
|
|
|
@ -120,10 +120,12 @@ mod tests {
|
|||
Mbox {
|
||||
delim: "/".into(),
|
||||
name: "INBOX".into(),
|
||||
desc: "desc".into(),
|
||||
},
|
||||
Mbox {
|
||||
delim: "/".into(),
|
||||
name: "Sent".into(),
|
||||
desc: "desc".into(),
|
||||
},
|
||||
],
|
||||
})
|
||||
|
@ -144,7 +146,7 @@ mod tests {
|
|||
) -> Result<Box<dyn Envelopes>> {
|
||||
unimplemented!()
|
||||
}
|
||||
fn add_msg(&mut self, _: &str, _: &[u8], _: &str) -> Result<Box<dyn ToString>> {
|
||||
fn add_msg(&mut self, _: &str, _: &[u8], _: &str) -> Result<String> {
|
||||
unimplemented!()
|
||||
}
|
||||
fn get_msg(&mut self, _: &str, _: &str) -> Result<Msg> {
|
||||
|
@ -179,9 +181,9 @@ mod tests {
|
|||
assert_eq!(
|
||||
concat![
|
||||
"\n",
|
||||
"DELIM │NAME │ATTRIBUTES \n",
|
||||
"/ │INBOX │NoSelect \n",
|
||||
"/ │Sent │NoInferiors, HasNoChildren \n",
|
||||
"DELIM │NAME │DESC \n",
|
||||
"/ │INBOX │desc \n",
|
||||
"/ │Sent │desc \n",
|
||||
"\n"
|
||||
],
|
||||
printer.writer.content
|
||||
|
|
Loading…
Reference in a new issue