From 3f1c5b5e65b68a61f17fa6263c7cd7ad7f9629b7 Mon Sep 17 00:00:00 2001 From: Christian Ebner Date: Mon, 11 Nov 2019 14:19:54 +0100 Subject: [PATCH] catalog: impl std::fmt::Display trait for CatalogEntryType Signed-off-by: Christian Ebner --- src/backup/catalog.rs | 6 +++--- src/pxar/catalog.rs | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/backup/catalog.rs b/src/backup/catalog.rs index 57fc12f9..0c299039 100644 --- a/src/backup/catalog.rs +++ b/src/backup/catalog.rs @@ -323,7 +323,7 @@ impl CatalogReader { match etype { CatalogEntryType::Directory => { - println!("{} {:?}", char::from(etype as u8), path); + println!("{} {:?}", etype, path); if offset > start { bail!("got wrong directory offset ({} > {})", offset, start); } @@ -335,14 +335,14 @@ impl CatalogReader { println!( "{} {:?} {} {}", - char::from(etype as u8), + etype, path, size, dt.to_rfc3339_opts(chrono::SecondsFormat::Secs, false), ); } _ => { - println!("{} {:?}", char::from(etype as u8), path); + println!("{} {:?}", etype, path); } } diff --git a/src/pxar/catalog.rs b/src/pxar/catalog.rs index fa2db236..d8e6b1d0 100644 --- a/src/pxar/catalog.rs +++ b/src/pxar/catalog.rs @@ -6,6 +6,7 @@ use failure::*; use std::convert::TryFrom; use std::ffi::CStr; +use std::fmt; #[repr(u8)] #[derive(Copy,Clone,PartialEq)] @@ -38,6 +39,12 @@ impl TryFrom for CatalogEntryType { } } +impl fmt::Display for CatalogEntryType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", char::from(*self as u8)) + } +} + pub trait BackupCatalogWriter { fn start_directory(&mut self, name: &CStr) -> Result<(), Error>; fn end_directory(&mut self) -> Result<(), Error>;