use anyhow::Result;
use crate::{
config::Account,
domain::{
imap::ImapServiceInterface,
msg::{Msg, TplOverride},
},
output::PrinterService,
};
pub fn new<'a, Printer: PrinterService>(
opts: TplOverride<'a>,
account: &'a Account,
printer: &'a mut Printer,
) -> Result<()> {
let tpl = Msg::default().to_tpl(opts, account);
printer.print(tpl)
}
pub fn reply<'a, Printer: PrinterService, ImapService: ImapServiceInterface<'a>>(
seq: &str,
all: bool,
opts: TplOverride<'a>,
account: &'a Account,
printer: &'a mut Printer,
imap: &'a mut ImapService,
) -> Result<()> {
let tpl = imap
.find_msg(seq)?
.into_reply(all, account)?
.to_tpl(opts, account);
printer.print(tpl)
}
pub fn forward<'a, Printer: PrinterService, ImapService: ImapServiceInterface<'a>>(
seq: &str,
opts: TplOverride<'a>,
account: &'a Account,
printer: &'a mut Printer,
imap: &'a mut ImapService,
) -> Result<()> {
let tpl = imap
.find_msg(seq)?
.into_forward(account)?
.to_tpl(opts, account);
printer.print(tpl)
}