Reduce noise in Debug for Frame (#329)

This commit is contained in:
Sean McArthur
2018-11-01 13:26:55 -07:00
committed by Carl Lerche
parent 4321caf6b3
commit 1a8015da4a
2 changed files with 23 additions and 15 deletions

View File

@@ -153,12 +153,16 @@ impl<T> From<Data<T>> for Frame<T> {
impl<T> fmt::Debug for Data<T> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.debug_struct("Data")
.field("stream_id", &self.stream_id)
.field("flags", &self.flags)
.field("pad_len", &self.pad_len)
// `data` purposefully excluded
.finish()
let mut f = fmt.debug_struct("Data");
f.field("stream_id", &self.stream_id);
if !self.flags.is_empty() {
f.field("flags", &self.flags);
}
if let Some(ref pad_len) = self.pad_len {
f.field("pad_len", pad_len);
}
// `data` bytes purposefully excluded
f.finish()
}
}
@@ -169,6 +173,10 @@ impl DataFlags {
DataFlags(bits & ALL)
}
fn is_empty(&self) -> bool {
self.0 == 0
}
fn is_end_stream(&self) -> bool {
self.0 & END_STREAM == END_STREAM
}