From dc376343d604f087c19537fe8cb4dc17908d2aa0 Mon Sep 17 00:00:00 2001 From: chansuke Date: Thu, 5 Nov 2020 04:24:57 +0900 Subject: [PATCH] Remove `#[derive(Debug)]` from library structs (#327) * Remove `#[derive(Debug)]` from library structs * Add manual debug impl for backward compatibility --- tarpc/src/rpc/client.rs | 8 +++++++- tarpc/src/rpc/server.rs | 38 +++++++++++++++++++++++++++++++++----- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/tarpc/src/rpc/client.rs b/tarpc/src/rpc/client.rs index 4c12737..24dc91a 100644 --- a/tarpc/src/rpc/client.rs +++ b/tarpc/src/rpc/client.rs @@ -8,6 +8,7 @@ use crate::context; use futures::prelude::*; +use std::fmt; use std::io; /// Provides a [`Client`] backed by a transport. @@ -127,7 +128,6 @@ impl Default for Config { /// A channel and dispatch pair. The dispatch drives the sending and receiving of requests /// and must be polled continuously or spawned. -#[derive(Debug)] pub struct NewClient { /// The new client. pub client: C, @@ -153,3 +153,9 @@ where Ok(self.client) } } + +impl fmt::Debug for NewClient { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(fmt, "NewClient") + } +} diff --git a/tarpc/src/rpc/server.rs b/tarpc/src/rpc/server.rs index 962d0ca..6da957e 100644 --- a/tarpc/src/rpc/server.rs +++ b/tarpc/src/rpc/server.rs @@ -36,7 +36,6 @@ pub use self::{ }; /// Manages clients, serving multiplexed requests over each connection. -#[derive(Debug)] pub struct Server { config: Config, ghost: PhantomData<(Req, Resp)>, @@ -48,6 +47,12 @@ impl Default for Server { } } +impl fmt::Debug for Server { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(fmt, "Server") + } +} + /// Settings that control the behavior of the server. #[derive(Clone, Debug)] pub struct Config { @@ -167,7 +172,6 @@ where /// BaseChannel lifts a Transport to a Channel by tracking in-flight requests. #[pin_project] -#[derive(Debug)] pub struct BaseChannel { config: Config, /// Writes responses to the wire and reads requests off the wire. @@ -236,6 +240,12 @@ where } } +impl fmt::Debug for BaseChannel { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "BaseChannel") + } +} + /// The server end of an open connection with a client, streaming in requests from, and sinking /// responses to, the client. /// @@ -384,7 +394,6 @@ where /// A running handler serving all requests coming over a channel. #[pin_project] -#[derive(Debug)] pub struct ClientHandler where C: Channel, @@ -508,9 +517,17 @@ where } } +impl fmt::Debug for ClientHandler +where + C: Channel, +{ + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(fmt, "ClientHandler") + } +} + /// A future fulfilling a single client request. #[pin_project] -#[derive(Debug)] pub struct RequestHandler { #[pin] resp: Abortable>, @@ -528,8 +545,13 @@ where } } +impl fmt::Debug for RequestHandler { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(fmt, "RequestHandler") + } +} + #[pin_project] -#[derive(Debug)] struct Resp { state: RespState, request_id: u64, @@ -614,6 +636,12 @@ where } } +impl fmt::Debug for Resp { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(fmt, "Resp") + } +} + impl Stream for ClientHandler where C: Channel,