Merge pull request #12 from sdroege/master

Implement std::fmt::Debug for all public types
This commit is contained in:
Sean McArthur
2016-11-14 11:11:12 -08:00
committed by GitHub
4 changed files with 23 additions and 0 deletions

View File

@@ -1,7 +1,9 @@
use std::io::Read; use std::io::Read;
use std::fs::File; use std::fs::File;
use std::fmt;
/// Body type for a request. /// Body type for a request.
#[derive(Debug)]
pub struct Body { pub struct Body {
reader: Kind, reader: Kind,
} }
@@ -71,6 +73,15 @@ impl From<File> for Body {
} }
} }
impl fmt::Debug for Kind {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
&Kind::Reader(_, ref v) => f.debug_tuple("Kind::Reader").field(&"_").field(v).finish(),
&Kind::Bytes(ref v) => f.debug_tuple("Kind::Bytes").field(v).finish(),
}
}
}
// Wraps a `std::io::Write`. // Wraps a `std::io::Write`.
//pub struct Pipe(Kind); //pub struct Pipe(Kind);

View File

@@ -22,6 +22,7 @@ static DEFAULT_USER_AGENT: &'static str = concat!(env!("CARGO_PKG_NAME"), "/", e
/// ///
/// The `Client` holds a connection pool internally, so it is advised that /// The `Client` holds a connection pool internally, so it is advised that
/// you create one and reuse it. /// you create one and reuse it.
#[derive(Debug)]
pub struct Client { pub struct Client {
inner: ::hyper::Client, inner: ::hyper::Client,
} }
@@ -81,6 +82,7 @@ fn new_hyper_client() -> ::Result<::hyper::Client> {
/// A builder to construct the properties of a `Request`. /// A builder to construct the properties of a `Request`.
#[derive(Debug)]
pub struct RequestBuilder<'a> { pub struct RequestBuilder<'a> {
client: &'a Client, client: &'a Client,
@@ -253,6 +255,7 @@ impl<'a> RequestBuilder<'a> {
} }
/// A Response to a submitted `Request`. /// A Response to a submitted `Request`.
#[derive(Debug)]
pub struct Response { pub struct Response {
inner: ::hyper::client::Response, inner: ::hyper::client::Response,
} }

View File

@@ -1,3 +1,4 @@
#[derive(Debug)]
pub struct RedirectPolicy { pub struct RedirectPolicy {
inner: () inner: ()
} }

View File

@@ -1,6 +1,7 @@
use std::io::{self, Read, Write}; use std::io::{self, Read, Write};
use std::net::SocketAddr; use std::net::SocketAddr;
use std::time::Duration; use std::time::Duration;
use std::fmt;
use hyper::net::{SslClient, HttpStream, NetworkStream}; use hyper::net::{SslClient, HttpStream, NetworkStream};
use native_tls::{TlsConnector, TlsStream as NativeTlsStream, HandshakeError}; use native_tls::{TlsConnector, TlsStream as NativeTlsStream, HandshakeError};
@@ -34,6 +35,13 @@ impl SslClient for TlsClient {
} }
} }
impl fmt::Debug for TlsClient {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("TlsClient").field(&"_").finish()
}
}
#[derive(Debug)]
pub struct TlsStream(NativeTlsStream<HttpStream>); pub struct TlsStream(NativeTlsStream<HttpStream>);
impl Read for TlsStream { impl Read for TlsStream {