From 168def3c2848f202c728a10185f3134f75c2b834 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 16 Nov 2020 15:08:12 -0500 Subject: [PATCH] Make AuthCertKeyIds sortable. --- tor-netdoc/src/doc/authcert.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tor-netdoc/src/doc/authcert.rs b/tor-netdoc/src/doc/authcert.rs index bc9102096..7e7943f25 100644 --- a/tor-netdoc/src/doc/authcert.rs +++ b/tor-netdoc/src/doc/authcert.rs @@ -99,6 +99,22 @@ pub struct AuthCertKeyIds { pub sk_fingerprint: rsa::RSAIdentity, } +impl Ord for AuthCertKeyIds { + fn cmp(&self, other: &AuthCertKeyIds) -> std::cmp::Ordering { + use std::cmp::Ordering::Equal; + match self.id_fingerprint.cmp(&other.id_fingerprint) { + Equal => self.sk_fingerprint.cmp(&other.sk_fingerprint), + r => r, + } + } +} + +impl PartialOrd for AuthCertKeyIds { + fn partial_cmp(&self, other: &AuthCertKeyIds) -> Option { + Some(self.cmp(other)) + } +} + /// An authority certificate whose signature and validity time we /// haven't checked. pub type UncheckedAuthCert = signed::SignatureGated>;