RelayId: implement id_type and as_bytes in terms of RelayIdRef

This eliminates some duplicated code.
This commit is contained in:
Ian Jackson 2023-04-27 19:02:26 +01:00
parent 58a0803667
commit c0aa600179
1 changed files with 2 additions and 8 deletions

View File

@ -124,10 +124,7 @@ impl RelayId {
/// Return the type of this relay identity. /// Return the type of this relay identity.
pub fn id_type(&self) -> RelayIdType { pub fn id_type(&self) -> RelayIdType {
match self { self.as_ref().id_type()
RelayId::Ed25519(_) => RelayIdType::Ed25519,
RelayId::Rsa(_) => RelayIdType::Rsa,
}
} }
/// Return a byte-slice corresponding to the contents of this identity. /// 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 /// handled with care to make sure that it does not get confused with an
/// identity of some other type. /// identity of some other type.
pub fn as_bytes(&self) -> &[u8] { pub fn as_bytes(&self) -> &[u8] {
match self { self.as_ref().as_bytes()
RelayId::Ed25519(key) => key.as_bytes(),
RelayId::Rsa(key) => key.as_bytes(),
}
} }
} }