Add static assertions
This commit is contained in:
parent
fcc2035b46
commit
c93e5a5020
|
@ -14,3 +14,4 @@ log = { version = "0.4", features = ["kv_unstable", "serde", "std", "kv_unstable
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
thiserror = "1"
|
thiserror = "1"
|
||||||
time = { version = "0.3", features = ["parsing", "serde", "formatting"] }
|
time = { version = "0.3", features = ["parsing", "serde", "formatting"] }
|
||||||
|
static_assertions = "1"
|
|
@ -71,6 +71,18 @@ impl AccountId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static_assertions::assert_not_impl_any!(
|
||||||
|
AccountId: PartialEq<crate::attachment::AttachmentId>,
|
||||||
|
PartialEq<crate::filter::FilterId>,
|
||||||
|
PartialEq<crate::list::ListId>,
|
||||||
|
PartialEq<crate::mention::MentionId>,
|
||||||
|
PartialEq<crate::notification::NotificationId>,
|
||||||
|
PartialEq<crate::relationship::RelationshipId>,
|
||||||
|
PartialEq<crate::push::SubscriptionId>,
|
||||||
|
PartialEq<crate::report::ReportId>,
|
||||||
|
PartialEq<crate::status::StatusId>,
|
||||||
|
);
|
||||||
|
|
||||||
/// A single name: value pair from a user's profile
|
/// A single name: value pair from a user's profile
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]
|
||||||
pub struct MetadataField {
|
pub struct MetadataField {
|
||||||
|
|
|
@ -41,6 +41,18 @@ impl AttachmentId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static_assertions::assert_not_impl_any!(
|
||||||
|
AttachmentId: PartialEq<crate::account::AccountId>,
|
||||||
|
PartialEq<crate::filter::FilterId>,
|
||||||
|
PartialEq<crate::list::ListId>,
|
||||||
|
PartialEq<crate::mention::MentionId>,
|
||||||
|
PartialEq<crate::notification::NotificationId>,
|
||||||
|
PartialEq<crate::relationship::RelationshipId>,
|
||||||
|
PartialEq<crate::report::ReportId>,
|
||||||
|
PartialEq<crate::push::SubscriptionId>,
|
||||||
|
PartialEq<crate::status::StatusId>,
|
||||||
|
);
|
||||||
|
|
||||||
/// Information about the attachment itself.
|
/// Information about the attachment itself.
|
||||||
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
|
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
|
||||||
pub struct Meta {
|
pub struct Meta {
|
||||||
|
|
|
@ -68,6 +68,18 @@ impl FilterId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static_assertions::assert_not_impl_any!(
|
||||||
|
FilterId: PartialEq<crate::account::AccountId>,
|
||||||
|
PartialEq<crate::attachment::AttachmentId>,
|
||||||
|
PartialEq<crate::list::ListId>,
|
||||||
|
PartialEq<crate::mention::MentionId>,
|
||||||
|
PartialEq<crate::notification::NotificationId>,
|
||||||
|
PartialEq<crate::relationship::RelationshipId>,
|
||||||
|
PartialEq<crate::push::SubscriptionId>,
|
||||||
|
PartialEq<crate::report::ReportId>,
|
||||||
|
PartialEq<crate::status::StatusId>,
|
||||||
|
);
|
||||||
|
|
||||||
/// Represents the various types of Filter contexts
|
/// Represents the various types of Filter contexts
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "lowercase")]
|
#[serde(rename_all = "lowercase")]
|
||||||
|
|
|
@ -23,3 +23,15 @@ impl ListId {
|
||||||
Self(value.into())
|
Self(value.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static_assertions::assert_not_impl_any!(
|
||||||
|
ListId: PartialEq<crate::account::AccountId>,
|
||||||
|
PartialEq<crate::attachment::AttachmentId>,
|
||||||
|
PartialEq<crate::filter::FilterId>,
|
||||||
|
PartialEq<crate::push::SubscriptionId>,
|
||||||
|
PartialEq<crate::mention::MentionId>,
|
||||||
|
PartialEq<crate::notification::NotificationId>,
|
||||||
|
PartialEq<crate::relationship::RelationshipId>,
|
||||||
|
PartialEq<crate::report::ReportId>,
|
||||||
|
PartialEq<crate::status::StatusId>,
|
||||||
|
);
|
||||||
|
|
|
@ -29,3 +29,15 @@ impl MentionId {
|
||||||
Self(value.into())
|
Self(value.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static_assertions::assert_not_impl_any!(
|
||||||
|
Mention: PartialEq<crate::account::AccountId>,
|
||||||
|
PartialEq<crate::attachment::AttachmentId>,
|
||||||
|
PartialEq<crate::filter::FilterId>,
|
||||||
|
PartialEq<crate::list::ListId>,
|
||||||
|
PartialEq<crate::notification::NotificationId>,
|
||||||
|
PartialEq<crate::relationship::RelationshipId>,
|
||||||
|
PartialEq<crate::push::SubscriptionId>,
|
||||||
|
PartialEq<crate::report::ReportId>,
|
||||||
|
PartialEq<crate::status::StatusId>,
|
||||||
|
);
|
||||||
|
|
|
@ -39,6 +39,18 @@ impl NotificationId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static_assertions::assert_not_impl_any!(
|
||||||
|
NotificationId: PartialEq<crate::account::AccountId>,
|
||||||
|
PartialEq<crate::attachment::AttachmentId>,
|
||||||
|
PartialEq<crate::filter::FilterId>,
|
||||||
|
PartialEq<crate::mention::MentionId>,
|
||||||
|
PartialEq<crate::list::ListId>,
|
||||||
|
PartialEq<crate::push::SubscriptionId>,
|
||||||
|
PartialEq<crate::relationship::RelationshipId>,
|
||||||
|
PartialEq<crate::report::ReportId>,
|
||||||
|
PartialEq<crate::status::StatusId>,
|
||||||
|
);
|
||||||
|
|
||||||
/// The type of notification.
|
/// The type of notification.
|
||||||
#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq)]
|
||||||
#[serde(rename_all = "lowercase")]
|
#[serde(rename_all = "lowercase")]
|
||||||
|
|
|
@ -43,6 +43,17 @@ impl SubscriptionId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static_assertions::assert_not_impl_any!(
|
||||||
|
SubscriptionId: PartialEq<crate::account::AccountId>,
|
||||||
|
PartialEq<crate::attachment::AttachmentId>,
|
||||||
|
PartialEq<crate::filter::FilterId>,
|
||||||
|
PartialEq<crate::mention::MentionId>,
|
||||||
|
PartialEq<crate::notification::NotificationId>,
|
||||||
|
PartialEq<crate::relationship::RelationshipId>,
|
||||||
|
PartialEq<crate::report::ReportId>,
|
||||||
|
PartialEq<crate::status::StatusId>,
|
||||||
|
);
|
||||||
|
|
||||||
pub mod add_subscription {
|
pub mod add_subscription {
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
|
|
@ -48,3 +48,15 @@ impl RelationshipId {
|
||||||
Self(value.into())
|
Self(value.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static_assertions::assert_not_impl_any!(
|
||||||
|
RelationshipId: PartialEq<crate::account::AccountId>,
|
||||||
|
PartialEq<crate::attachment::AttachmentId>,
|
||||||
|
PartialEq<crate::filter::FilterId>,
|
||||||
|
PartialEq<crate::push::SubscriptionId>,
|
||||||
|
PartialEq<crate::mention::MentionId>,
|
||||||
|
PartialEq<crate::notification::NotificationId>,
|
||||||
|
PartialEq<crate::list::ListId>,
|
||||||
|
PartialEq<crate::report::ReportId>,
|
||||||
|
PartialEq<crate::status::StatusId>,
|
||||||
|
);
|
||||||
|
|
|
@ -27,3 +27,15 @@ impl ReportId {
|
||||||
Self(value.into())
|
Self(value.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static_assertions::assert_not_impl_any!(
|
||||||
|
ReportId: PartialEq<crate::account::AccountId>,
|
||||||
|
PartialEq<crate::attachment::AttachmentId>,
|
||||||
|
PartialEq<crate::filter::FilterId>,
|
||||||
|
PartialEq<crate::push::SubscriptionId>,
|
||||||
|
PartialEq<crate::mention::MentionId>,
|
||||||
|
PartialEq<crate::notification::NotificationId>,
|
||||||
|
PartialEq<crate::relationship::RelationshipId>,
|
||||||
|
PartialEq<crate::list::ListId>,
|
||||||
|
PartialEq<crate::status::StatusId>,
|
||||||
|
);
|
||||||
|
|
|
@ -82,6 +82,18 @@ impl StatusId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static_assertions::assert_not_impl_any!(
|
||||||
|
StatusId: PartialEq<crate::account::AccountId>,
|
||||||
|
PartialEq<crate::attachment::AttachmentId>,
|
||||||
|
PartialEq<crate::filter::FilterId>,
|
||||||
|
PartialEq<crate::push::SubscriptionId>,
|
||||||
|
PartialEq<crate::mention::MentionId>,
|
||||||
|
PartialEq<crate::notification::NotificationId>,
|
||||||
|
PartialEq<crate::relationship::RelationshipId>,
|
||||||
|
PartialEq<crate::report::ReportId>,
|
||||||
|
PartialEq<crate::list::ListId>,
|
||||||
|
);
|
||||||
|
|
||||||
/// A mention of another user.
|
/// A mention of another user.
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||||
pub struct Mention {
|
pub struct Mention {
|
||||||
|
|
Loading…
Reference in New Issue