Require Debug for StreamWrapper
This commit is contained in:
parent
2de8ecad6e
commit
a6d9a214a6
@ -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;
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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<Box<StreamWrapper>> {
|
||||
/// 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<usize> {
|
||||
self.0.read(buf)
|
||||
|
Loading…
Reference in New Issue
Block a user