From f467f4666e523b9e58e2097b0f5e1b78f3e83837 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 2 Mar 2022 17:10:47 +0000 Subject: [PATCH] Replace manual Debug impl with educe in tor-chanmgr --- Cargo.lock | 2 ++ crates/tor-chanmgr/Cargo.toml | 2 ++ crates/tor-chanmgr/src/event.rs | 12 +++++------- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e54613447..e02d44bb0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3124,6 +3124,7 @@ version = "0.1.0" dependencies = [ "async-trait", "derive_more", + "educe", "float_eq", "futures", "futures-await-test", @@ -3131,6 +3132,7 @@ dependencies = [ "postage", "rand 0.8.5", "thiserror", + "tor-bytes", "tor-error", "tor-linkspec", "tor-llcrypto", diff --git a/crates/tor-chanmgr/Cargo.toml b/crates/tor-chanmgr/Cargo.toml index 5eb7c30f2..fc5d5ea94 100644 --- a/crates/tor-chanmgr/Cargo.toml +++ b/crates/tor-chanmgr/Cargo.toml @@ -13,6 +13,7 @@ repository="https://gitlab.torproject.org/tpo/core/arti.git/" [features] [dependencies] +tor-bytes = { path="../tor-bytes", version = "0.1.0"} tor-error = { path="../tor-error", version = "0.1.0"} tor-rtcompat = { path="../tor-rtcompat", version = "0.1.0"} tor-proto = { path="../tor-proto", version = "0.1.0"} @@ -21,6 +22,7 @@ tor-llcrypto = { path="../tor-llcrypto", version = "0.1.0"} async-trait = "0.1.2" derive_more = "0.99" +educe = "0.4.6" futures = "0.3.14" postage = { version = "0.4", default-features = false, features = ["futures-traits"] } rand = "0.8" diff --git a/crates/tor-chanmgr/src/event.rs b/crates/tor-chanmgr/src/event.rs index 2f9c32a91..3340658e6 100644 --- a/crates/tor-chanmgr/src/event.rs +++ b/crates/tor-chanmgr/src/event.rs @@ -1,12 +1,14 @@ //! Code for exporting events from the channel manager. #![allow(dead_code, unreachable_pub)] +use educe::Educe; use futures::{Stream, StreamExt}; use postage::watch; use std::{ fmt, time::{Duration, Instant}, }; +use tor_bytes::skip_fmt; /// The status of our connection to the internet. #[derive(Default, Debug, Clone)] @@ -122,21 +124,17 @@ impl fmt::Display for ConnStatus { /// Note that the bootstrap status is not monotonic: we might become less /// bootstrapped than we were before. (For example, the internet could go /// down.) -#[derive(Clone)] +#[derive(Clone, Educe)] +#[educe(Debug)] pub struct ConnStatusEvents { /// The receiver that implements this stream. /// /// (We wrap it in a new type here so that we can replace the implementation /// later on if we need to.) + #[educe(Debug(method = "skip_fmt"))] inner: watch::Receiver, } -impl fmt::Debug for ConnStatusEvents { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("ConnStatusEvents").finish_non_exhaustive() - } -} - impl Stream for ConnStatusEvents { type Item = ConnStatus; fn poll_next(