From 8c7ef7fd937616798780d43f80a6b46507bc3433 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Mon, 15 Feb 2016 14:41:45 -0800 Subject: [PATCH] feat(client): Implement Debug for Client Protocol doesn't extend Debug so we have to leave that out of the output unfortunately. --- src/client/mod.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/client/mod.rs b/src/client/mod.rs index 5d48fb60d0..37969092d7 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -58,6 +58,7 @@ use std::default::Default; use std::io::{self, copy, Read}; use std::iter::Extend; +use std::fmt; use std::time::Duration; @@ -92,6 +93,16 @@ pub struct Client { write_timeout: Option, } +impl fmt::Debug for Client { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("Client") + .field("redirect_policy", &self.redirect_policy) + .field("read_timeout", &self.read_timeout) + .field("write_timeout", &self.write_timeout) + .finish() + } +} + impl Client { /// Create a new Client. @@ -405,6 +416,16 @@ pub enum RedirectPolicy { FollowIf(fn(&Url) -> bool), } +impl fmt::Debug for RedirectPolicy { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + RedirectPolicy::FollowNone => fmt.write_str("FollowNone"), + RedirectPolicy::FollowAll => fmt.write_str("FollowAll"), + RedirectPolicy::FollowIf(_) => fmt.write_str("FollowIf"), + } + } +} + // This is a hack because of upstream typesystem issues. impl Clone for RedirectPolicy { fn clone(&self) -> RedirectPolicy {