From 9dd40762fcd52083a3dc1a58cb0f3a21210b6772 Mon Sep 17 00:00:00 2001 From: David Rusu Date: Mon, 2 Nov 2020 22:47:38 -0500 Subject: [PATCH] Impl Debug on a few datatypes --- src/api.rs | 2 +- src/bootstrap_cache.rs | 2 +- src/endpoint.rs | 11 +++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/api.rs b/src/api.rs index dfa6f965..f45e8966 100644 --- a/src/api.rs +++ b/src/api.rs @@ -61,7 +61,7 @@ impl Message { } /// Main QuicP2p instance to communicate with QuicP2p using an async API -#[derive(Clone)] +#[derive(Debug, Clone)] pub struct QuicP2p { local_addr: SocketAddr, allow_random_port: bool, diff --git a/src/bootstrap_cache.rs b/src/bootstrap_cache.rs index 81289585..665bbfb8 100644 --- a/src/bootstrap_cache.rs +++ b/src/bootstrap_cache.rs @@ -24,7 +24,7 @@ use std::{ const MAX_CACHE_SIZE: usize = 200; /// A very simple LRU like struct that writes itself to disk every 10 entries added. -#[derive(Clone)] +#[derive(Debug, Clone)] pub struct BootstrapCache { peers: VecDeque, cache_path: PathBuf, diff --git a/src/endpoint.rs b/src/endpoint.rs index 8f5b1a38..c9c3096c 100644 --- a/src/endpoint.rs +++ b/src/endpoint.rs @@ -28,6 +28,17 @@ pub struct Endpoint { client_cfg: quinn::ClientConfig, } +impl std::fmt::Debug for Endpoint { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Endpoint") + .field("local_addr", &self.local_addr) + .field("quic_endpoint", &"".to_string()) + .field("quic_incoming", &self.quic_incoming) + .field("client_cfg", &self.client_cfg) + .finish() + } +} + impl Endpoint { pub(crate) fn new( quic_endpoint: quinn::Endpoint,