Add static assertions

This commit is contained in:
D. Scott Boggs 2023-01-09 08:39:42 -05:00 committed by Scott Boggs
parent fcc2035b46
commit c93e5a5020
11 changed files with 120 additions and 0 deletions

View File

@ -14,3 +14,4 @@ log = { version = "0.4", features = ["kv_unstable", "serde", "std", "kv_unstable
serde = { version = "1", features = ["derive"] }
thiserror = "1"
time = { version = "0.3", features = ["parsing", "serde", "formatting"] }
static_assertions = "1"

View File

@ -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
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]
pub struct MetadataField {

View File

@ -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.
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
pub struct Meta {

View File

@ -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
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]

View File

@ -23,3 +23,15 @@ impl ListId {
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>,
);

View File

@ -29,3 +29,15 @@ impl MentionId {
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>,
);

View File

@ -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.
#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq)]
#[serde(rename_all = "lowercase")]

View File

@ -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 {
use serde::Serialize;

View File

@ -48,3 +48,15 @@ impl RelationshipId {
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>,
);

View File

@ -27,3 +27,15 @@ impl ReportId {
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>,
);

View File

@ -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.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct Mention {