use serde::{Deserialize, Serialize};
use std::fmt;
macro_rules! name {
($(#[$m:meta])* $t:ident) => {
$(#[$m])*
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
#[serde(transparent)]
pub struct $t(pub String);
impl $t {
pub fn new(s: impl Into<String>) -> Self {
$t(s.into())
}
pub fn as_str(&self) -> &str {
&self.0
}
}
impl fmt::Display for $t {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(&self.0)
}
}
impl From<&str> for $t {
fn from(s: &str) -> Self {
$t(s.to_string())
}
}
};
}
name!(
ProjectId
);
name!(
RoleId
);
name!(
Permission
);
name!(
StreamId
);
name!(
RecordId
);