Replace manual Debug impl with educe in tor-dirmgr

This commit is contained in:
Ian Jackson 2022-03-02 17:13:18 +00:00
parent f467f4666e
commit 210b9b70a8
3 changed files with 9 additions and 8 deletions

2
Cargo.lock generated
View File

@ -3245,6 +3245,7 @@ dependencies = [
"derive_builder", "derive_builder",
"derive_more", "derive_more",
"digest 0.10.3", "digest 0.10.3",
"educe",
"event-listener", "event-listener",
"float_eq", "float_eq",
"fslock", "fslock",
@ -3265,6 +3266,7 @@ dependencies = [
"tempfile", "tempfile",
"thiserror", "thiserror",
"time", "time",
"tor-bytes",
"tor-checkable", "tor-checkable",
"tor-circmgr", "tor-circmgr",
"tor-config", "tor-config",

View File

@ -19,6 +19,7 @@ routerdesc = ["tor-dirclient/routerdesc"]
[dependencies] [dependencies]
retry-error = { path = "../retry-error", version = "0.1.0"} 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-checkable = { path = "../tor-checkable", version = "0.1.0"}
tor-circmgr = { path = "../tor-circmgr", version = "0.1.0"} tor-circmgr = { path = "../tor-circmgr", version = "0.1.0"}
tor-config = { path = "../tor-config", 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_builder = "0.10"
derive_more = "0.99" derive_more = "0.99"
digest = "0.10.0" digest = "0.10.0"
educe = "0.4.6"
event-listener = "2" event-listener = "2"
futures = "0.3.14" futures = "0.3.14"
fslock = { version = "0.2.0" } fslock = { version = "0.2.0" }

View File

@ -16,8 +16,10 @@ use std::{
time::SystemTime, time::SystemTime,
}; };
use educe::Educe;
use futures::{stream::Stream, Future, StreamExt}; use futures::{stream::Stream, Future, StreamExt};
use time::OffsetDateTime; use time::OffsetDateTime;
use tor_bytes::skip_fmt;
use tor_netdoc::doc::netstatus; use tor_netdoc::doc::netstatus;
/// An event that a DirMgr can broadcast to indicate that a change in /// An event that a DirMgr can broadcast to indicate that a change in
@ -495,12 +497,14 @@ impl DirStatus {
} }
/// A stream of [`DirBootstrapStatus`] events. /// A stream of [`DirBootstrapStatus`] events.
#[derive(Clone)] #[derive(Clone, Educe)]
#[educe(Debug)]
pub struct DirBootstrapEvents { pub struct DirBootstrapEvents {
/// The `postage::watch::Receiver` that we're wrapping. /// 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 /// 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. /// can migrate to some other implementation in the future if we want.
#[educe(Debug(method = "skip_fmt"))]
pub(crate) inner: postage::watch::Receiver<DirBootstrapStatus>, pub(crate) inner: postage::watch::Receiver<DirBootstrapStatus>,
} }
@ -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)] #[allow(clippy::unwrap_used)]
#[cfg(test)] #[cfg(test)]
mod test { mod test {