Replace manual Debug impl with educe in tor-guardmgr
This commit is contained in:
parent
f474a583f1
commit
b2d8c14c90
|
@ -3303,6 +3303,7 @@ name = "tor-guardmgr"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"derive_builder",
|
"derive_builder",
|
||||||
|
"educe",
|
||||||
"futures",
|
"futures",
|
||||||
"humantime-serde",
|
"humantime-serde",
|
||||||
"itertools",
|
"itertools",
|
||||||
|
@ -3311,6 +3312,7 @@ dependencies = [
|
||||||
"retain_mut",
|
"retain_mut",
|
||||||
"serde",
|
"serde",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
|
"tor-bytes",
|
||||||
"tor-config",
|
"tor-config",
|
||||||
"tor-error",
|
"tor-error",
|
||||||
"tor-linkspec",
|
"tor-linkspec",
|
||||||
|
|
|
@ -18,6 +18,7 @@ default = []
|
||||||
testing = []
|
testing = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
tor-bytes = { path="../tor-bytes", version = "0.1.0"}
|
||||||
tor-config = { path="../tor-config", version = "0.1.0"}
|
tor-config = { path="../tor-config", version = "0.1.0"}
|
||||||
tor-error = { path="../tor-error", version = "0.1.0"}
|
tor-error = { path="../tor-error", version = "0.1.0"}
|
||||||
tor-netdir = { path="../tor-netdir", version = "0.1.0"}
|
tor-netdir = { path="../tor-netdir", version = "0.1.0"}
|
||||||
|
@ -29,6 +30,7 @@ tor-rtcompat = { path="../tor-rtcompat", version = "0.1.0"}
|
||||||
tor-units = { path="../tor-units", version = "0.1.0"}
|
tor-units = { path="../tor-units", version = "0.1.0"}
|
||||||
|
|
||||||
derive_builder = "0.10"
|
derive_builder = "0.10"
|
||||||
|
educe = "0.4.6"
|
||||||
futures = "0.3.14"
|
futures = "0.3.14"
|
||||||
humantime-serde = "1"
|
humantime-serde = "1"
|
||||||
itertools = "0.10.1"
|
itertools = "0.10.1"
|
||||||
|
|
|
@ -9,17 +9,20 @@
|
||||||
//! handled via [`GuardUsable`].
|
//! handled via [`GuardUsable`].
|
||||||
use crate::{daemon, GuardId};
|
use crate::{daemon, GuardId};
|
||||||
|
|
||||||
|
use educe::Educe;
|
||||||
use futures::{
|
use futures::{
|
||||||
channel::{mpsc::UnboundedSender, oneshot},
|
channel::{mpsc::UnboundedSender, oneshot},
|
||||||
Future,
|
Future,
|
||||||
};
|
};
|
||||||
use pin_project::pin_project;
|
use pin_project::pin_project;
|
||||||
use std::fmt::{self, Debug};
|
use std::fmt::Debug;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::sync::atomic::{AtomicU64, Ordering};
|
use std::sync::atomic::{AtomicU64, Ordering};
|
||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
|
use tor_bytes::skip_fmt;
|
||||||
|
|
||||||
/// A future used to see if we have "permission" to use a guard.
|
/// A future used to see if we have "permission" to use a guard.
|
||||||
///
|
///
|
||||||
/// For efficiency, the [`GuardMgr`](crate::GuardMgr) implementation sometimes gives
|
/// For efficiency, the [`GuardMgr`](crate::GuardMgr) implementation sometimes gives
|
||||||
|
@ -101,6 +104,8 @@ pub enum GuardStatus {
|
||||||
/// The `GuardMgr` needs to know about these statuses, so that it can tell
|
/// The `GuardMgr` needs to know about these statuses, so that it can tell
|
||||||
/// whether the guard is running or not.
|
/// whether the guard is running or not.
|
||||||
#[must_use = "You need to report the status of any guard that you asked for"]
|
#[must_use = "You need to report the status of any guard that you asked for"]
|
||||||
|
#[derive(Educe)]
|
||||||
|
#[educe(Debug)]
|
||||||
pub struct GuardMonitor {
|
pub struct GuardMonitor {
|
||||||
/// The Id that we're going to report about.
|
/// The Id that we're going to report about.
|
||||||
id: RequestId,
|
id: RequestId,
|
||||||
|
@ -119,19 +124,10 @@ pub struct GuardMonitor {
|
||||||
/// TODO: This doesn't really need to be an Option, but we use None
|
/// TODO: This doesn't really need to be an Option, but we use None
|
||||||
/// here to indicate that we've already used the sender, and it can't
|
/// here to indicate that we've already used the sender, and it can't
|
||||||
/// be used again.
|
/// be used again.
|
||||||
|
#[educe(Debug(method = "skip_fmt"))]
|
||||||
snd: Option<UnboundedSender<daemon::Msg>>,
|
snd: Option<UnboundedSender<daemon::Msg>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Debug for GuardMonitor {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
f.debug_struct("GuardMonitor")
|
|
||||||
.field("id", &self.id)
|
|
||||||
.field("pending_status", &self.pending_status)
|
|
||||||
.field("ignore_indeterminate", &self.ignore_indeterminate)
|
|
||||||
.finish_non_exhaustive()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl GuardMonitor {
|
impl GuardMonitor {
|
||||||
/// Create a new GuardMonitor object.
|
/// Create a new GuardMonitor object.
|
||||||
pub(crate) fn new(id: RequestId, snd: UnboundedSender<daemon::Msg>) -> Self {
|
pub(crate) fn new(id: RequestId, snd: UnboundedSender<daemon::Msg>) -> Self {
|
||||||
|
|
Loading…
Reference in New Issue