From c0aa6001790afc1cc28666c394bc6982b3ee1328 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 27 Apr 2023 19:02:26 +0100 Subject: [PATCH] RelayId: implement id_type and as_bytes in terms of RelayIdRef This eliminates some duplicated code. --- crates/tor-linkspec/src/ids.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/crates/tor-linkspec/src/ids.rs b/crates/tor-linkspec/src/ids.rs index 3a8b4e812..3afb36f8d 100644 --- a/crates/tor-linkspec/src/ids.rs +++ b/crates/tor-linkspec/src/ids.rs @@ -124,10 +124,7 @@ impl RelayId { /// Return the type of this relay identity. pub fn id_type(&self) -> RelayIdType { - match self { - RelayId::Ed25519(_) => RelayIdType::Ed25519, - RelayId::Rsa(_) => RelayIdType::Rsa, - } + self.as_ref().id_type() } /// Return a byte-slice corresponding to the contents of this identity. @@ -136,10 +133,7 @@ impl RelayId { /// handled with care to make sure that it does not get confused with an /// identity of some other type. pub fn as_bytes(&self) -> &[u8] { - match self { - RelayId::Ed25519(key) => key.as_bytes(), - RelayId::Rsa(key) => key.as_bytes(), - } + self.as_ref().as_bytes() } }