Skip to content

Commit

Permalink
Display RawEvent data in hex (#168)
Browse files Browse the repository at this point in the history
So that printing the RawEvent won't comsume more than the whole screen.
  • Loading branch information
liuchengxu authored Sep 21, 2020
1 parent e843bd6 commit 0c7454d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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> {
Expand Down

0 comments on commit 0c7454d

Please sign in to comment.