diff --git a/src/middleware/mod.rs b/src/middleware/mod.rs index ef357f29..24b647b4 100644 --- a/src/middleware/mod.rs +++ b/src/middleware/mod.rs @@ -443,7 +443,7 @@ impl From<&Value> for Hash { } } -#[derive(Clone, Debug, PartialEq, Eq, Hash)] +#[derive(Clone, Debug, Eq)] pub struct Key { name: String, hash: Hash, @@ -466,6 +466,18 @@ impl Key { } } +impl hash::Hash for Key { + fn hash(&self, state: &mut H) { + self.hash.hash(state); + } +} + +impl PartialEq for Key { + fn eq(&self, other: &Self) -> bool { + self.hash == other.hash + } +} + // A Key can easily be created from a string-like type impl From for Key where @@ -531,7 +543,7 @@ impl JsonSchema for Key { } } -#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)] +#[derive(Clone, Debug, Eq, Serialize, Deserialize, JsonSchema)] #[serde(rename_all = "camelCase")] pub struct AnchoredKey { pub pod_id: PodId, @@ -544,6 +556,19 @@ impl AnchoredKey { } } +impl hash::Hash for AnchoredKey { + fn hash(&self, state: &mut H) { + self.pod_id.hash(state); + self.key.hash.hash(state); + } +} + +impl PartialEq for AnchoredKey { + fn eq(&self, other: &Self) -> bool { + self.pod_id == other.pod_id && self.key.hash == other.key.hash + } +} + impl fmt::Display for AnchoredKey { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.pod_id.fmt(f)?;