Add Display impl for events
use std::{
collections::HashMap,
+ fmt,
path::{Path, PathBuf},
process::ExitStatus,
};
@@ -61,3 +62,25 @@ impl Event {
})
}
}
+
+impl fmt::Display for Event {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ write!(f, "Event")?;
+ for p in &self.particulars {
+ match p {
+ Particle::Path(p) => write!(f, " path={}", p.display())?,
+ Particle::Source(s) => write!(f, " source={:?}", s)?,
+ Particle::Process(p) => write!(f, " process={}", p)?,
+ Particle::Signal(s) => write!(f, " signal={:?}", s)?,
+ Particle::ProcessCompletion(None) => write!(f, " command-completed")?,
+ Particle::ProcessCompletion(Some(c)) => write!(f, " command-completed({})", c)?,
+ }
+ }
+
+ if !self.metadata.is_empty() {
+ write!(f, " meta: {:?}", self.metadata)?;
+ }
+
+ Ok(())
+ }
+}
