From 0c7454dfcd75e267eca73e4364b737515772c579 Mon Sep 17 00:00:00 2001 From: Liu-Cheng Xu Date: Mon, 21 Sep 2020 17:32:41 +0800 Subject: [PATCH] Display RawEvent data in hex (#168) So that printing the RawEvent won't comsume more than the whole screen. --- src/events.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/events.rs b/src/events.rs index e7f45295d6..ec05909c52 100644 --- a/src/events.rs +++ b/src/events.rs @@ -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, } +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 {