use serde::{Deserialize, Serialize};
use std::fmt;
macro_rules! id_newtype {
($name:ident) => {
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[serde(transparent)]
pub struct $name(String);
impl $name {
pub fn new(value: impl Into<String>) -> Self {
Self(value.into())
}
pub fn as_str(&self) -> &str {
&self.0
}
pub fn into_string(self) -> String {
self.0
}
}
impl fmt::Display for $name {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
}
};
}
id_newtype!(MessageId);
id_newtype!(CaseUid);
id_newtype!(ArchiveUid);
id_newtype!(PushId);