From de6e5f331d8fc4b8e1b725540d530f305dc72351 Mon Sep 17 00:00:00 2001 From: Aaron Weiss Date: Sat, 27 Jan 2018 20:39:35 +0100 Subject: [PATCH] Added debug derivations for irc::client types (fixes #104). --- src/client/conn.rs | 19 +++++++++++++++++++ src/client/server/mod.rs | 5 ++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/client/conn.rs b/src/client/conn.rs index 106a539..8dbdc0e 100644 --- a/src/client/conn.rs +++ b/src/client/conn.rs @@ -55,6 +55,25 @@ pub enum ConnectionFuture<'a> { Mock(&'a Config), } +impl<'a> fmt::Debug for ConnectionFuture<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!( + f, + "{}({:?}, ...)", + match *self { + ConnectionFuture::Unsecured(_, _) => "ConnectionFuture::Unsecured", + ConnectionFuture::Secured(_, _) => "ConnectionFuture::Secured", + ConnectionFuture::Mock(_) => "ConnectionFuture::Mock", + }, + match *self { + ConnectionFuture::Unsecured(cfg, _) | + ConnectionFuture::Secured(cfg, _) | + ConnectionFuture::Mock(cfg) => cfg, + } + ) + } +} + impl<'a> Future for ConnectionFuture<'a> { type Item = Connection; type Error = error::Error; diff --git a/src/client/server/mod.rs b/src/client/server/mod.rs index 4537fba..db82895 100644 --- a/src/client/server/mod.rs +++ b/src/client/server/mod.rs @@ -203,6 +203,7 @@ pub trait Server { /// traditional use cases. To learn more, you can view the documentation for the /// [futures](https://docs.rs/futures/) crate, or the tutorials for /// [tokio](https://tokio.rs/docs/getting-started/futures/). +#[derive(Debug)] pub struct ServerStream { state: Arc, stream: SplitStream, @@ -224,6 +225,7 @@ impl Stream for ServerStream { } /// Thread-safe internal state for an IRC server connection. +#[derive(Debug)] struct ServerState { /// The configuration used with this connection. config: Config, @@ -597,7 +599,7 @@ impl ServerState { /// server after connection. Cloning an `IrcServer` is relatively cheap, as it's equivalent to /// cloning a single `Arc`. This may be useful for setting up multiple threads with access to one /// connection. -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct IrcServer { /// The internal, thread-safe server state. state: Arc, @@ -801,6 +803,7 @@ impl IrcServer { /// use cases. To learn more, you can view the documentation for the /// [futures](https://docs.rs/futures/) crate, or the tutorials for /// [tokio](https://tokio.rs/docs/getting-started/futures/). +#[derive(Debug)] pub struct IrcServerFuture<'a> { conn: ConnectionFuture<'a>, handle: Handle,