From 679228873a040e9fc8f78fb02533a665f60f01e9 Mon Sep 17 00:00:00 2001 From: Nutomic Date: Mon, 13 Nov 2023 10:38:58 +0100 Subject: [PATCH] Implement PartialEq for testing (#81) --- src/fetch/collection_id.rs | 10 ++++++++++ src/protocol/public_key.rs | 2 +- src/protocol/values.rs | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/fetch/collection_id.rs b/src/fetch/collection_id.rs index 8f42008..068ab0b 100644 --- a/src/fetch/collection_id.rs +++ b/src/fetch/collection_id.rs @@ -96,3 +96,13 @@ where CollectionId(Box::new(url), PhantomData::) } } + +impl PartialEq for CollectionId +where + Kind: Collection, + for<'de2> ::Kind: serde::Deserialize<'de2>, +{ + fn eq(&self, other: &Self) -> bool { + self.0.eq(&other.0) && self.1 == other.1 + } +} diff --git a/src/protocol/public_key.rs b/src/protocol/public_key.rs index ecfcd3c..d36ee2b 100644 --- a/src/protocol/public_key.rs +++ b/src/protocol/public_key.rs @@ -6,7 +6,7 @@ use url::Url; /// Public key of actors which is used for HTTP signatures. /// /// This needs to be federated in the `public_key` field of all actors. -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] #[serde(rename_all = "camelCase")] pub struct PublicKey { /// Id of this private key. diff --git a/src/protocol/values.rs b/src/protocol/values.rs index 0c01097..4a87b3c 100644 --- a/src/protocol/values.rs +++ b/src/protocol/values.rs @@ -35,7 +35,7 @@ use serde::{Deserialize, Serialize}; /// Media type for markdown text. /// /// -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] pub enum MediaTypeMarkdown { /// `text/markdown` #[serde(rename = "text/markdown")] @@ -45,7 +45,7 @@ pub enum MediaTypeMarkdown { /// Media type for HTML text. /// /// -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] pub enum MediaTypeHtml { /// `text/html` #[serde(rename = "text/html")]