1 #[cfg(feature = "full")]
2 use diesel_ltree::Ltree;
3 use serde::{Deserialize, Serialize};
6 fmt::{Display, Formatter},
11 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Default, Serialize, Deserialize)]
12 #[cfg_attr(feature = "full", derive(DieselNewType))]
13 pub struct PostId(pub i32);
15 impl fmt::Display for PostId {
16 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
17 write!(f, "{}", self.0)
21 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Default, Serialize, Deserialize)]
22 #[cfg_attr(feature = "full", derive(DieselNewType))]
23 pub struct PersonId(pub i32);
25 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
26 #[cfg_attr(feature = "full", derive(DieselNewType))]
27 pub struct CommentId(pub i32);
29 impl fmt::Display for CommentId {
30 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
31 write!(f, "{}", self.0)
35 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Default, Serialize, Deserialize)]
36 #[cfg_attr(feature = "full", derive(DieselNewType))]
37 pub struct CommunityId(pub i32);
39 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Default, Serialize, Deserialize)]
40 #[cfg_attr(feature = "full", derive(DieselNewType))]
41 pub struct LocalUserId(pub i32);
43 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
44 #[cfg_attr(feature = "full", derive(DieselNewType))]
45 pub struct PrivateMessageId(i32);
47 impl fmt::Display for PrivateMessageId {
48 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
49 write!(f, "{}", self.0)
53 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
54 #[cfg_attr(feature = "full", derive(DieselNewType))]
55 pub struct PersonMentionId(i32);
57 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
58 #[cfg_attr(feature = "full", derive(DieselNewType))]
59 pub struct PersonBlockId(i32);
61 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
62 #[cfg_attr(feature = "full", derive(DieselNewType))]
63 pub struct CommunityBlockId(i32);
65 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
66 #[cfg_attr(feature = "full", derive(DieselNewType))]
67 pub struct CommentReportId(i32);
69 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
70 #[cfg_attr(feature = "full", derive(DieselNewType))]
71 pub struct PostReportId(i32);
73 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
74 #[cfg_attr(feature = "full", derive(DieselNewType))]
75 pub struct PrivateMessageReportId(i32);
77 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
78 #[cfg_attr(feature = "full", derive(DieselNewType))]
79 pub struct SiteId(i32);
81 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
82 #[cfg_attr(feature = "full", derive(DieselNewType))]
83 pub struct LanguageId(pub i32);
85 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
86 #[cfg_attr(feature = "full", derive(DieselNewType))]
87 pub struct LocalUserLanguageId(pub i32);
89 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
90 #[cfg_attr(feature = "full", derive(DieselNewType))]
91 pub struct SiteLanguageId(pub i32);
93 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
94 #[cfg_attr(feature = "full", derive(DieselNewType))]
95 pub struct CommunityLanguageId(pub i32);
97 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
98 #[cfg_attr(feature = "full", derive(DieselNewType))]
99 pub struct CommentReplyId(i32);
101 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
102 #[cfg_attr(feature = "full", derive(DieselNewType))]
103 pub struct InstanceId(i32);
105 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
106 #[cfg_attr(feature = "full", derive(DieselNewType))]
107 pub struct LocalSiteId(i32);
110 #[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
111 #[cfg_attr(feature = "full", derive(AsExpression, FromSqlRow))]
112 #[cfg_attr(feature = "full", diesel(sql_type = diesel::sql_types::Text))]
113 pub struct DbUrl(pub(crate) Url);
115 #[cfg(feature = "full")]
116 #[derive(Serialize, Deserialize)]
117 #[serde(remote = "Ltree")]
118 /// Do remote derivation for the Ltree struct
119 pub struct LtreeDef(pub String);
121 impl Display for DbUrl {
122 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
123 self.to_owned().0.fmt(f)
127 // the project doesnt compile with From
128 #[allow(clippy::from_over_into)]
129 impl Into<DbUrl> for Url {
130 fn into(self) -> DbUrl {
134 #[allow(clippy::from_over_into)]
135 impl Into<Url> for DbUrl {
136 fn into(self) -> Url {
141 impl Deref for DbUrl {
144 fn deref(&self) -> &Self::Target {