From 0fb92ee735136a07c832124df521b96a6779bd39 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Thu, 16 Apr 2015 10:04:51 -0700 Subject: [PATCH] feat(debug): add Debug impls for StatusClass, Server, and Listening --- src/client/mod.rs | 2 +- src/server/mod.rs | 8 ++++++++ src/status.rs | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/client/mod.rs b/src/client/mod.rs index 05ce9cd856..b4d46a38a4 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -349,7 +349,7 @@ pub enum RedirectPolicy { // This is a hack because of upstream typesystem issues. impl Clone for RedirectPolicy { fn clone(&self) -> RedirectPolicy { - *self + *self } } diff --git a/src/server/mod.rs b/src/server/mod.rs index a8e3347759..674f43e0dc 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -1,4 +1,5 @@ //! HTTP Server +use std::fmt; use std::io::{ErrorKind, BufWriter, Write}; use std::marker::PhantomData; use std::net::{SocketAddr, ToSocketAddrs}; @@ -34,6 +35,7 @@ mod listener; /// /// Once listening, it will create a `Request`/`Response` pair for each /// incoming connection, and hand them to the provided handler. +#[derive(Debug)] pub struct Server<'a, H: Handler, L = HttpListener> { handler: H, ssl: Option<(&'a Path, &'a Path)>, @@ -187,6 +189,12 @@ pub struct Listening { pub socket: SocketAddr, } +impl fmt::Debug for Listening { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Listening {{ socket: {:?} }}", self.socket) + } +} + impl Drop for Listening { fn drop(&mut self) { let _ = self._guard.take().map(|g| g.join()); diff --git a/src/status.rs b/src/status.rs index 62c1d09321..2b9df6484a 100644 --- a/src/status.rs +++ b/src/status.rs @@ -558,7 +558,7 @@ impl Ord for StatusCode { /// /// This can be used in cases where a status code’s meaning is unknown, also, /// to get the appropriate *category* of status. -#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Copy)] +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Copy)] pub enum StatusClass { /// 1xx (Informational): The request was received, continuing process Informational,