Skip to content

Commit 782ad71

Browse files
nanoqshsdroege
authored andcommitted
Hide internal state in Debug for ByteWriter
1 parent 5241a19 commit 782ad71

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/bytes.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//! a [`WebSocketStream`](crate::WebSocketStream) or a [`WebSocketSender`](crate::WebSocketSender).
33
44
use std::{
5-
io,
5+
fmt, io,
66
pin::Pin,
77
task::{Context, Poll},
88
};
@@ -15,7 +15,6 @@ use crate::{tungstenite::Bytes, Message, WsError};
1515
///
1616
/// Every write sends a binary message. If you want to group writes together, consider wrapping
1717
/// this with a `BufWriter`.
18-
#[derive(Debug)]
1918
pub struct ByteWriter<S> {
2019
sender: S,
2120
state: State,
@@ -41,7 +40,18 @@ impl<S> ByteWriter<S> {
4140
}
4241
}
4342

44-
#[derive(Debug)]
43+
impl<S> fmt::Debug for ByteWriter<S>
44+
where
45+
S: fmt::Debug,
46+
{
47+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
48+
f.debug_struct("ByteWriter")
49+
.field("sender", &self.sender)
50+
.field("state", &"..")
51+
.finish()
52+
}
53+
}
54+
4555
enum State {
4656
Open,
4757
Closing(Option<Message>),

0 commit comments

Comments
 (0)