use std::{fmt, ops};
use serde::{Deserialize, Serialize};
use smallstr::SmallString;
mod community_id;
mod post_id;
macro_rules! impl_id {
($name:ident, $docs:expr) => {
#[doc = $docs]
#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq, Hash)]
pub struct $name(pub i64);
impl ops::Deref for $name {
type Target = i64;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl fmt::Display for $name {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.0)
}
}
};
}
impl_id!(CommentId, "A comment ID.");
impl_id!(CommunityId, "A community ID.");
impl_id!(FlagId, "A flag ID.");
impl_id!(PollOptionId, "A poll option ID.");
impl_id!(PostId, "A post ID.");
impl_id!(RemoteId, "A remote ID.");
impl_id!(UserId, "A user ID.");
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Hash)]
pub struct PageId(pub SmallString<[u8; 24]>);
impl ops::Deref for PageId {
type Target = str;
fn deref(&self) -> &Self::Target {
&self.0
}
}