Commit ebfd7349 authored by Ian Jackson's avatar Ian Jackson
Browse files

Move skip_fmt into tor-basic-utils

Code motion and the minimal mechanical changes.

As per
  !375 (comment 2783078)
parent aba68088
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -138,7 +138,7 @@ dependencies = [
 "thiserror",
 "tokio",
 "tokio-util",
 "tor-bytes",
 "tor-basic-utils",
 "tor-chanmgr",
 "tor-circmgr",
 "tor-config",
@@ -3084,7 +3084,6 @@ dependencies = [
 "arrayref",
 "bytes",
 "digest 0.10.3",
 "educe",
 "generic-array",
 "getrandom 0.2.5",
 "hex-literal",
@@ -3107,6 +3106,7 @@ dependencies = [
 "hex-literal",
 "rand 0.8.5",
 "thiserror",
 "tor-basic-utils",
 "tor-bytes",
 "tor-cert",
 "tor-error",
@@ -3142,7 +3142,7 @@ dependencies = [
 "postage",
 "rand 0.8.5",
 "thiserror",
 "tor-bytes",
 "tor-basic-utils",
 "tor-error",
 "tor-linkspec",
 "tor-llcrypto",
@@ -3179,7 +3179,7 @@ dependencies = [
 "serde",
 "static_assertions",
 "thiserror",
 "tor-bytes",
 "tor-basic-utils",
 "tor-chanmgr",
 "tor-config",
 "tor-error",
@@ -3276,7 +3276,7 @@ dependencies = [
 "tempfile",
 "thiserror",
 "time",
 "tor-bytes",
 "tor-basic-utils",
 "tor-checkable",
 "tor-circmgr",
 "tor-config",
@@ -3327,7 +3327,7 @@ dependencies = [
 "retain_mut",
 "serde",
 "thiserror",
 "tor-bytes",
 "tor-basic-utils",
 "tor-config",
 "tor-error",
 "tor-linkspec",
@@ -3470,6 +3470,7 @@ dependencies = [
 "thiserror",
 "tokio",
 "tokio-util",
 "tor-basic-utils",
 "tor-bytes",
 "tor-cell",
 "tor-cert",
+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ error_detail = [ ]
experimental-api = []

[dependencies]
tor-bytes = { path="../tor-bytes", version = "0.1.0"}
tor-basic-utils = { path="../tor-basic-utils", version = "0.1.0"}
tor-circmgr = { path="../tor-circmgr", version = "0.1.0"}
tor-config = { path="../tor-config", version = "0.1.0"}
tor-chanmgr = { path="../tor-chanmgr", version = "0.1.0"}
+1 −1
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ use std::{borrow::Cow, fmt, time::SystemTime};
use derive_more::Display;
use educe::Educe;
use futures::{Stream, StreamExt};
use tor_bytes::skip_fmt;
use tor_basic_utils::skip_fmt;
use tor_chanmgr::{ConnBlockage, ConnStatus, ConnStatusEvents};
use tor_dirmgr::{DirBootstrapEvents, DirBootstrapStatus};
use tracing::debug;
+37 −0
Original line number Diff line number Diff line
@@ -28,3 +28,40 @@
#![deny(clippy::unnecessary_wraps)]
#![warn(clippy::unseparated_literal_suffix)]
#![deny(clippy::unwrap_used)]

use std::fmt;

// ----------------------------------------------------------------------

/// Function with the signature of `Debug::fmt` that just prints `".."`
///
/// ```
/// use educe::Educe;
/// use tor_basic_utils::skip_fmt;
///
/// #[derive(Educe, Default)]
/// #[educe(Debug)]
/// struct Wombat {
///     visible: usize,
///
///     #[educe(Debug(method = "skip_fmt"))]
///     invisible: [u8; 2],
/// }
///
/// assert_eq!( format!("{:?}", &Wombat::default()),
///             "Wombat { visible: 0, invisible: .. }" );
/// ```
//
// This function is here in tor-bytes because crates that want to use it will largely
// be trying to avoid dumping packet data.
// But, it may at some point want to move to a lower-layer crate.
// If we do that, we should `pub use` it here, if we don't want a semver break.
pub fn skip_fmt<T>(_: &T, f: &mut fmt::Formatter) -> fmt::Result {
    /// Inner function avoids code bloat due to generics
    fn inner(f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "..")
    }
    inner(f)
}

// ----------------------------------------------------------------------
+0 −1
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ thiserror = "1"

[dev-dependencies]
hex-literal = "0.3"
educe = "0.4.6"

[target.wasm32-unknown-unknown.dependencies]
getrandom = { version = "0.2.3", features = ["js"] }
Loading