Skip to content

Commit

Permalink
feat(client): Implement Debug for Client
Browse files Browse the repository at this point in the history
Protocol doesn't extend Debug so we have to leave that out of the
output unfortunately.
  • Loading branch information
sfackler committed Feb 15, 2016
1 parent e8245aa commit 8c7ef7f
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -92,6 +93,16 @@ pub struct Client {
write_timeout: Option<Duration>,
}

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.
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 8c7ef7f

Please sign in to comment.