From 210b9b70a8e7a49ad814242aada31fce1cb0c66c Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 2 Mar 2022 17:13:18 +0000 Subject: [PATCH] Replace manual Debug impl with educe in tor-dirmgr --- Cargo.lock | 2 ++ crates/tor-dirmgr/Cargo.toml | 2 ++ crates/tor-dirmgr/src/event.rs | 13 +++++-------- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e02d44bb0..f0e9d9f07 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3245,6 +3245,7 @@ dependencies = [ "derive_builder", "derive_more", "digest 0.10.3", + "educe", "event-listener", "float_eq", "fslock", @@ -3265,6 +3266,7 @@ dependencies = [ "tempfile", "thiserror", "time", + "tor-bytes", "tor-checkable", "tor-circmgr", "tor-config", diff --git a/crates/tor-dirmgr/Cargo.toml b/crates/tor-dirmgr/Cargo.toml index 6f43b9375..4814df54c 100644 --- a/crates/tor-dirmgr/Cargo.toml +++ b/crates/tor-dirmgr/Cargo.toml @@ -19,6 +19,7 @@ routerdesc = ["tor-dirclient/routerdesc"] [dependencies] retry-error = { path = "../retry-error", version = "0.1.0"} +tor-bytes = { path="../tor-bytes", version = "0.1.0"} tor-checkable = { path = "../tor-checkable", version = "0.1.0"} tor-circmgr = { path = "../tor-circmgr", version = "0.1.0"} tor-config = { path = "../tor-config", version = "0.1.0"} @@ -35,6 +36,7 @@ base64 = "0.13.0" derive_builder = "0.10" derive_more = "0.99" digest = "0.10.0" +educe = "0.4.6" event-listener = "2" futures = "0.3.14" fslock = { version = "0.2.0" } diff --git a/crates/tor-dirmgr/src/event.rs b/crates/tor-dirmgr/src/event.rs index 48935012f..ed2918d95 100644 --- a/crates/tor-dirmgr/src/event.rs +++ b/crates/tor-dirmgr/src/event.rs @@ -16,8 +16,10 @@ use std::{ time::SystemTime, }; +use educe::Educe; use futures::{stream::Stream, Future, StreamExt}; use time::OffsetDateTime; +use tor_bytes::skip_fmt; use tor_netdoc::doc::netstatus; /// An event that a DirMgr can broadcast to indicate that a change in @@ -495,12 +497,14 @@ impl DirStatus { } /// A stream of [`DirBootstrapStatus`] events. -#[derive(Clone)] +#[derive(Clone, Educe)] +#[educe(Debug)] pub struct DirBootstrapEvents { /// The `postage::watch::Receiver` that we're wrapping. /// /// We wrap this type so that we don't expose its entire API, and so that we /// can migrate to some other implementation in the future if we want. + #[educe(Debug(method = "skip_fmt"))] pub(crate) inner: postage::watch::Receiver, } @@ -515,13 +519,6 @@ impl Stream for DirBootstrapEvents { } } -impl std::fmt::Debug for DirBootstrapEvents { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("DirBootstrapStatusEvents") - .finish_non_exhaustive() - } -} - #[allow(clippy::unwrap_used)] #[cfg(test)] mod test {