1 use serde::{Deserialize, Serialize};
4 fmt::{Display, Formatter},
9 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Default, Serialize, Deserialize)]
10 #[cfg_attr(feature = "full", derive(DieselNewType))]
11 pub struct PostId(pub i32);
13 impl fmt::Display for PostId {
14 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15 write!(f, "{}", self.0)
19 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Default, Serialize, Deserialize)]
20 #[cfg_attr(feature = "full", derive(DieselNewType))]
21 pub struct PersonId(pub i32);
23 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
24 #[cfg_attr(feature = "full", derive(DieselNewType))]
25 pub struct CommentId(pub i32);
27 impl fmt::Display for CommentId {
28 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
29 write!(f, "{}", self.0)
33 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Default, Serialize, Deserialize)]
34 #[cfg_attr(feature = "full", derive(DieselNewType))]
35 pub struct CommunityId(pub i32);
37 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Default, Serialize, Deserialize)]
38 #[cfg_attr(feature = "full", derive(DieselNewType))]
39 pub struct LocalUserId(pub i32);
41 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
42 #[cfg_attr(feature = "full", derive(DieselNewType))]
43 pub struct PrivateMessageId(i32);
45 impl fmt::Display for PrivateMessageId {
46 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
47 write!(f, "{}", self.0)
51 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
52 #[cfg_attr(feature = "full", derive(DieselNewType))]
53 pub struct PersonMentionId(i32);
55 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
56 #[cfg_attr(feature = "full", derive(DieselNewType))]
57 pub struct PersonBlockId(i32);
59 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
60 #[cfg_attr(feature = "full", derive(DieselNewType))]
61 pub struct CommunityBlockId(i32);
63 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
64 #[cfg_attr(feature = "full", derive(DieselNewType))]
65 pub struct CommentReportId(i32);
67 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
68 #[cfg_attr(feature = "full", derive(DieselNewType))]
69 pub struct PostReportId(i32);
72 #[derive(Clone, PartialEq, Serialize, Deserialize, Debug)]
73 #[cfg_attr(feature = "full", derive(AsExpression, FromSqlRow))]
74 #[cfg_attr(feature = "full", sql_type = "diesel::sql_types::Text")]
75 pub struct DbUrl(pub(crate) Url);
77 impl Display for DbUrl {
78 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
79 self.to_owned().0.fmt(f)
83 // the project doesnt compile with From
84 #[allow(clippy::from_over_into)]
85 impl Into<DbUrl> for Url {
86 fn into(self) -> DbUrl {
90 #[allow(clippy::from_over_into)]
91 impl Into<Url> for DbUrl {
92 fn into(self) -> Url {
97 impl Deref for DbUrl {
100 fn deref(&self) -> &Self::Target {