Initial commit

This commit is contained in:
Ivan I. Ovchinnikov
2026-11-16 13:59:40 +03:00
commit 84ca3d07f8
66 changed files with 3774 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
use serde::{Deserialize, Serialize};
use std::fmt;
macro_rules! string_id {
($name:ident) => {
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(transparent)]
pub struct $name(pub String);
impl $name {
pub fn new(value: impl Into<String>) -> Self {
Self(value.into())
}
pub fn as_str(&self) -> &str {
&self.0
}
}
impl fmt::Display for $name {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
}
};
}
string_id!(ServerId);
string_id!(TeamId);
string_id!(ChannelId);
string_id!(UserId);
string_id!(PostId);
impl Default for ServerId {
fn default() -> Self {
Self::new("default")
}
}