Skip to content

Commit a6d9a21

Browse files
committed
Require Debug for StreamWrapper
1 parent 2de8eca commit a6d9a21

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/io/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ mod openssl;
1111
mod security_framework;
1212

1313
/// A trait implemented by SSL adaptors.
14-
pub trait StreamWrapper: Read+Write+Send {
14+
pub trait StreamWrapper: fmt::Debug + Read + Write + Send {
1515
/// Returns a reference to the underlying `Stream`.
1616
fn get_ref(&self) -> &Stream;
1717

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,7 @@ impl fmt::Debug for Connection {
826826
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
827827
let conn = self.conn.borrow();
828828
fmt.debug_struct("Connection")
829+
.field("stream", &conn.stream.get_ref())
829830
.field("cancel_data", &conn.cancel_data)
830831
.field("notifications", &conn.notifications.len())
831832
.field("transaction_depth", &conn.trans_depth)

src/priv_io.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use byteorder::ReadBytesExt;
22
use net2::TcpStreamExt;
33
use std::io;
44
use std::io::prelude::*;
5+
use std::fmt;
56
use std::net::TcpStream;
67
use std::time::Duration;
78
use bufstream::BufStream;
@@ -43,6 +44,16 @@ impl ReadTimeout for BufStream<Box<StreamWrapper>> {
4344
/// Unix platforms and `AsRawSocket` on Windows platforms.
4445
pub struct Stream(InternalStream);
4546

47+
impl fmt::Debug for Stream {
48+
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
49+
match self.0 {
50+
InternalStream::Tcp(ref s) => fmt::Debug::fmt(s, fmt),
51+
#[cfg(feature = "unix_socket")]
52+
InternalStream::Unix(ref s) => fmt::Debug::fmt(s, fmt),
53+
}
54+
}
55+
}
56+
4657
impl Read for Stream {
4758
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
4859
self.0.read(buf)

0 commit comments

Comments
 (0)