diff --git a/src/io/mod.rs b/src/io/mod.rs index 2e53af42..7677b04f 100644 --- a/src/io/mod.rs +++ b/src/io/mod.rs @@ -11,7 +11,7 @@ mod openssl; mod security_framework; /// A trait implemented by SSL adaptors. -pub trait StreamWrapper: Read+Write+Send { +pub trait StreamWrapper: fmt::Debug + Read + Write + Send { /// Returns a reference to the underlying `Stream`. fn get_ref(&self) -> &Stream; diff --git a/src/lib.rs b/src/lib.rs index 7374bff8..4f832b6a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -826,6 +826,7 @@ impl fmt::Debug for Connection { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { let conn = self.conn.borrow(); fmt.debug_struct("Connection") + .field("stream", &conn.stream.get_ref()) .field("cancel_data", &conn.cancel_data) .field("notifications", &conn.notifications.len()) .field("transaction_depth", &conn.trans_depth) diff --git a/src/priv_io.rs b/src/priv_io.rs index 139f1535..1e7f066b 100644 --- a/src/priv_io.rs +++ b/src/priv_io.rs @@ -2,6 +2,7 @@ use byteorder::ReadBytesExt; use net2::TcpStreamExt; use std::io; use std::io::prelude::*; +use std::fmt; use std::net::TcpStream; use std::time::Duration; use bufstream::BufStream; @@ -43,6 +44,16 @@ impl ReadTimeout for BufStream> { /// Unix platforms and `AsRawSocket` on Windows platforms. pub struct Stream(InternalStream); +impl fmt::Debug for Stream { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.0 { + InternalStream::Tcp(ref s) => fmt::Debug::fmt(s, fmt), + #[cfg(feature = "unix_socket")] + InternalStream::Unix(ref s) => fmt::Debug::fmt(s, fmt), + } + } +} + impl Read for Stream { fn read(&mut self, buf: &mut [u8]) -> io::Result { self.0.read(buf)