2021-10-16 07:33:38 -06:00
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use std::{
|
|
|
|
fmt,
|
|
|
|
fmt::{Display, Formatter},
|
2022-02-07 12:23:12 -07:00
|
|
|
ops::Deref,
|
2021-10-16 07:33:38 -06:00
|
|
|
};
|
|
|
|
use url::Url;
|
|
|
|
|
2022-05-03 11:44:13 -06:00
|
|
|
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Default, Serialize, Deserialize)]
|
|
|
|
#[cfg_attr(feature = "full", derive(DieselNewType))]
|
2021-10-16 07:33:38 -06:00
|
|
|
pub struct PostId(pub i32);
|
|
|
|
|
|
|
|
impl fmt::Display for PostId {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
write!(f, "{}", self.0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-03 11:44:13 -06:00
|
|
|
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Default, Serialize, Deserialize)]
|
|
|
|
#[cfg_attr(feature = "full", derive(DieselNewType))]
|
2021-10-16 07:33:38 -06:00
|
|
|
pub struct PersonId(pub i32);
|
|
|
|
|
2022-05-03 11:44:13 -06:00
|
|
|
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
|
|
|
|
#[cfg_attr(feature = "full", derive(DieselNewType))]
|
2021-10-16 07:33:38 -06:00
|
|
|
pub struct CommentId(pub i32);
|
|
|
|
|
|
|
|
impl fmt::Display for CommentId {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
write!(f, "{}", self.0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-03 11:44:13 -06:00
|
|
|
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Default, Serialize, Deserialize)]
|
|
|
|
#[cfg_attr(feature = "full", derive(DieselNewType))]
|
2021-10-16 07:33:38 -06:00
|
|
|
pub struct CommunityId(pub i32);
|
|
|
|
|
2022-05-03 11:44:13 -06:00
|
|
|
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Default, Serialize, Deserialize)]
|
|
|
|
#[cfg_attr(feature = "full", derive(DieselNewType))]
|
2021-10-16 07:33:38 -06:00
|
|
|
pub struct LocalUserId(pub i32);
|
|
|
|
|
2022-05-03 11:44:13 -06:00
|
|
|
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
|
|
|
|
#[cfg_attr(feature = "full", derive(DieselNewType))]
|
2021-10-16 07:33:38 -06:00
|
|
|
pub struct PrivateMessageId(i32);
|
|
|
|
|
|
|
|
impl fmt::Display for PrivateMessageId {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
write!(f, "{}", self.0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-03 11:44:13 -06:00
|
|
|
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
|
|
|
|
#[cfg_attr(feature = "full", derive(DieselNewType))]
|
2021-10-16 07:33:38 -06:00
|
|
|
pub struct PersonMentionId(i32);
|
|
|
|
|
2022-05-03 11:44:13 -06:00
|
|
|
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
|
|
|
|
#[cfg_attr(feature = "full", derive(DieselNewType))]
|
2021-10-16 07:33:38 -06:00
|
|
|
pub struct PersonBlockId(i32);
|
|
|
|
|
2022-05-03 11:44:13 -06:00
|
|
|
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
|
|
|
|
#[cfg_attr(feature = "full", derive(DieselNewType))]
|
2021-10-16 07:33:38 -06:00
|
|
|
pub struct CommunityBlockId(i32);
|
|
|
|
|
2022-05-03 11:44:13 -06:00
|
|
|
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
|
|
|
|
#[cfg_attr(feature = "full", derive(DieselNewType))]
|
2021-10-16 07:33:38 -06:00
|
|
|
pub struct CommentReportId(i32);
|
|
|
|
|
2022-05-03 11:44:13 -06:00
|
|
|
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
|
|
|
|
#[cfg_attr(feature = "full", derive(DieselNewType))]
|
2021-10-16 07:33:38 -06:00
|
|
|
pub struct PostReportId(i32);
|
|
|
|
|
|
|
|
#[repr(transparent)]
|
2022-05-03 11:44:13 -06:00
|
|
|
#[derive(Clone, PartialEq, Serialize, Deserialize, Debug)]
|
|
|
|
#[cfg_attr(feature = "full", derive(AsExpression, FromSqlRow))]
|
|
|
|
#[cfg_attr(feature = "full", sql_type = "diesel::sql_types::Text")]
|
|
|
|
pub struct DbUrl(pub(crate) Url);
|
2021-10-16 07:33:38 -06:00
|
|
|
|
|
|
|
impl Display for DbUrl {
|
|
|
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
|
|
|
self.to_owned().0.fmt(f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-04 18:24:10 -06:00
|
|
|
// the project doesnt compile with From
|
|
|
|
#[allow(clippy::from_over_into)]
|
|
|
|
impl Into<DbUrl> for Url {
|
|
|
|
fn into(self) -> DbUrl {
|
|
|
|
DbUrl(self)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#[allow(clippy::from_over_into)]
|
|
|
|
impl Into<Url> for DbUrl {
|
|
|
|
fn into(self) -> Url {
|
|
|
|
self.0
|
2021-10-16 07:33:38 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-07 12:23:12 -07:00
|
|
|
impl Deref for DbUrl {
|
|
|
|
type Target = Url;
|
|
|
|
|
|
|
|
fn deref(&self) -> &Self::Target {
|
|
|
|
&self.0
|
|
|
|
}
|
|
|
|
}
|