catalog: impl std::fmt::Display trait for CatalogEntryType

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
This commit is contained in:
Christian Ebner 2019-11-11 14:19:54 +01:00 committed by Dietmar Maurer
parent cd88ccae99
commit 3f1c5b5e65
2 changed files with 10 additions and 3 deletions

View File

@ -323,7 +323,7 @@ impl <R: Read + Seek> CatalogReader<R> {
match etype { match etype {
CatalogEntryType::Directory => { CatalogEntryType::Directory => {
println!("{} {:?}", char::from(etype as u8), path); println!("{} {:?}", etype, path);
if offset > start { if offset > start {
bail!("got wrong directory offset ({} > {})", offset, start); bail!("got wrong directory offset ({} > {})", offset, start);
} }
@ -335,14 +335,14 @@ impl <R: Read + Seek> CatalogReader<R> {
println!( println!(
"{} {:?} {} {}", "{} {:?} {} {}",
char::from(etype as u8), etype,
path, path,
size, size,
dt.to_rfc3339_opts(chrono::SecondsFormat::Secs, false), dt.to_rfc3339_opts(chrono::SecondsFormat::Secs, false),
); );
} }
_ => { _ => {
println!("{} {:?}", char::from(etype as u8), path); println!("{} {:?}", etype, path);
} }
} }

View File

@ -6,6 +6,7 @@
use failure::*; use failure::*;
use std::convert::TryFrom; use std::convert::TryFrom;
use std::ffi::CStr; use std::ffi::CStr;
use std::fmt;
#[repr(u8)] #[repr(u8)]
#[derive(Copy,Clone,PartialEq)] #[derive(Copy,Clone,PartialEq)]
@ -38,6 +39,12 @@ impl TryFrom<u8> 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 { pub trait BackupCatalogWriter {
fn start_directory(&mut self, name: &CStr) -> Result<(), Error>; fn start_directory(&mut self, name: &CStr) -> Result<(), Error>;
fn end_directory(&mut self) -> Result<(), Error>; fn end_directory(&mut self) -> Result<(), Error>;