Display RawEvent data in hex (#168)

So that printing the RawEvent won't comsume more than the whole screen.
This commit is contained in:
Liu-Cheng Xu
2020-09-21 17:32:41 +08:00
committed by GitHub
parent e843bd670f
commit 0c7454dfcd
+10 -1
View File
@@ -52,7 +52,6 @@ use crate::{
};
/// Raw bytes for an Event
#[derive(Debug)]
pub struct RawEvent {
/// The name of the module from whence the Event originated
pub module: String,
@@ -62,6 +61,16 @@ pub struct RawEvent {
pub data: Vec<u8>,
}
impl std::fmt::Debug for RawEvent {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("RawEvent")
.field("module", &self.module)
.field("variant", &self.variant)
.field("data", &hex::encode(&self.data))
.finish()
}
}
/// Events decoder.
#[derive(Debug)]
pub struct EventsDecoder<T> {