Skip to content

Commit 8c7ef7f

Browse files
committed
feat(client): Implement Debug for Client
Protocol doesn't extend Debug so we have to leave that out of the output unfortunately.
1 parent e8245aa commit 8c7ef7f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/client/mod.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
use std::default::Default;
5959
use std::io::{self, copy, Read};
6060
use std::iter::Extend;
61+
use std::fmt;
6162

6263
use std::time::Duration;
6364

@@ -92,6 +93,16 @@ pub struct Client {
9293
write_timeout: Option<Duration>,
9394
}
9495

96+
impl fmt::Debug for Client {
97+
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
98+
fmt.debug_struct("Client")
99+
.field("redirect_policy", &self.redirect_policy)
100+
.field("read_timeout", &self.read_timeout)
101+
.field("write_timeout", &self.write_timeout)
102+
.finish()
103+
}
104+
}
105+
95106
impl Client {
96107

97108
/// Create a new Client.
@@ -405,6 +416,16 @@ pub enum RedirectPolicy {
405416
FollowIf(fn(&Url) -> bool),
406417
}
407418

419+
impl fmt::Debug for RedirectPolicy {
420+
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
421+
match *self {
422+
RedirectPolicy::FollowNone => fmt.write_str("FollowNone"),
423+
RedirectPolicy::FollowAll => fmt.write_str("FollowAll"),
424+
RedirectPolicy::FollowIf(_) => fmt.write_str("FollowIf"),
425+
}
426+
}
427+
}
428+
408429
// This is a hack because of upstream typesystem issues.
409430
impl Clone for RedirectPolicy {
410431
fn clone(&self) -> RedirectPolicy {

0 commit comments

Comments
 (0)