use anyhow::Result;
use crate::{
domain::{Flags, ImapServiceInterface},
output::PrinterService,
};
pub fn add<'a, Printer: PrinterService, ImapService: ImapServiceInterface<'a>>(
seq_range: &'a str,
flags: Vec<&'a str>,
printer: &'a mut Printer,
imap: &'a mut ImapService,
) -> Result<()> {
let flags = Flags::from(flags);
imap.add_flags(seq_range, &flags)?;
printer.print(format!(
r#"Flag(s) "{}" successfully added to message(s) "{}""#,
flags, seq_range
))
}
pub fn remove<'a, Printer: PrinterService, ImapService: ImapServiceInterface<'a>>(
seq_range: &'a str,
flags: Vec<&'a str>,
printer: &'a mut Printer,
imap: &'a mut ImapService,
) -> Result<()> {
let flags = Flags::from(flags);
imap.remove_flags(seq_range, &flags)?;
printer.print(format!(
r#"Flag(s) "{}" successfully removed from message(s) "{}""#,
flags, seq_range
))
}
pub fn set<'a, Printer: PrinterService, ImapService: ImapServiceInterface<'a>>(
seq_range: &'a str,
flags: Vec<&'a str>,
printer: &'a mut Printer,
imap: &'a mut ImapService,
) -> Result<()> {
let flags = Flags::from(flags);
imap.set_flags(seq_range, &flags)?;
printer.print(format!(
r#"Flag(s) "{}" successfully set for message(s) "{}""#,
flags, seq_range
))
}