diff --git a/Cargo.lock b/Cargo.lock index 99f4fbe53..d501a491a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3399,6 +3399,7 @@ name = "tor-guardmgr" version = "0.1.0" dependencies = [ "derive_builder", + "derive_more", "educe", "futures", "humantime-serde", diff --git a/crates/tor-guardmgr/Cargo.toml b/crates/tor-guardmgr/Cargo.toml index 38e83aadf..8a4b59bba 100644 --- a/crates/tor-guardmgr/Cargo.toml +++ b/crates/tor-guardmgr/Cargo.toml @@ -30,6 +30,7 @@ tor-rtcompat = { path = "../tor-rtcompat", version = "0.1.0" } tor-units = { path = "../tor-units", version = "0.1.0" } derive_builder = "0.11" +derive_more = "0.99" educe = "0.4.6" futures = "0.3.14" humantime-serde = "1.1.1" diff --git a/crates/tor-guardmgr/src/ids.rs b/crates/tor-guardmgr/src/ids.rs index 59f50d473..92ca66aed 100644 --- a/crates/tor-guardmgr/src/ids.rs +++ b/crates/tor-guardmgr/src/ids.rs @@ -1,5 +1,6 @@ //! Identifier objects used to specify guards and/or fallbacks. +use derive_more::AsRef; use serde::{Deserialize, Serialize}; use tor_llcrypto::pk; @@ -16,7 +17,7 @@ pub(crate) struct IdPair { /// /// This is a separate type from GuardId and FirstHopId to avoid confusion /// about what kind of object we're identifying. -#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] +#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd, AsRef)] pub(crate) struct FallbackId(pub(crate) IdPair); impl FallbackId { @@ -29,17 +30,12 @@ impl FallbackId { Self::new(*target.ed_identity(), *target.rsa_identity()) } } -impl AsRef for FallbackId { - fn as_ref(&self) -> &IdPair { - &self.0 - } -} /// An identifier for a sampled guard. /// /// This is a separate type from GuardId and FirstHopId to avoid confusion /// about what kind of object we're identifying. -#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Hash, Ord, PartialOrd)] +#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Hash, Ord, PartialOrd, AsRef)] #[serde(transparent)] pub(crate) struct GuardId(pub(crate) IdPair); @@ -53,11 +49,6 @@ impl GuardId { Self::new(*target.ed_identity(), *target.rsa_identity()) } } -impl AsRef for GuardId { - fn as_ref(&self) -> &IdPair { - &self.0 - } -} /// Implementation type held inside of FirstHopId. ///