use std::fmt;
#[derive(Clone, Debug, PartialEq)]
pub struct MessageIdList(Vec<String>);
impl std::ops::Deref for MessageIdList {
type Target = Vec<String>;
fn deref(&self) -> &Vec<String> {
&self.0
}
}
impl std::ops::DerefMut for MessageIdList {
fn deref_mut(&mut self) -> &mut Vec<String> {
&mut self.0
}
}
impl fmt::Display for MessageIdList {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut first = true;
for msgid in self.iter() {
if !first {
write!(f, " ")?;
}
write!(f, "{}", msgid)?;
first = false;
}
Ok(())
}
}
pub fn msgidparse(ids: &str) -> Result<MessageIdList, &'static str> {
let ids = ids.split_whitespace().map(String::from).collect::<Vec<String>>();
Ok(MessageIdList(ids))
}