[pbs-devel] [PATCH proxmox-backup 08/15] pxar: typedef on_error as ErrorHandler

Fabian Grünbichler f.gruenbichler at proxmox.com
Mon Jan 25 14:42:53 CET 2021


Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
 src/bin/pxar.rs     | 4 ++--
 src/pxar/extract.rs | 6 ++++--
 src/pxar/mod.rs     | 2 +-
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/bin/pxar.rs b/src/bin/pxar.rs
index 4d2308bf..3d92dbe0 100644
--- a/src/bin/pxar.rs
+++ b/src/bin/pxar.rs
@@ -17,7 +17,7 @@ use proxmox::api::cli::*;
 use proxmox::api::api;
 
 use proxmox_backup::tools;
-use proxmox_backup::pxar::{fuse, format_single_line_entry, ENCODER_MAX_ENTRIES, Flags};
+use proxmox_backup::pxar::{fuse, format_single_line_entry, ENCODER_MAX_ENTRIES, ErrorHandler, Flags};
 
 fn extract_archive_from_reader<R: std::io::Read>(
     reader: &mut R,
@@ -27,7 +27,7 @@ fn extract_archive_from_reader<R: std::io::Read>(
     verbose: bool,
     match_list: &[MatchEntry],
     extract_match_default: bool,
-    on_error: Option<Box<dyn FnMut(Error) -> Result<(), Error> + Send>>,
+    on_error: Option<ErrorHandler>,
 ) -> Result<(), Error> {
     proxmox_backup::pxar::extract_archive(
         pxar::decoder::Decoder::from_std(reader)?,
diff --git a/src/pxar/extract.rs b/src/pxar/extract.rs
index 12f9054d..e22fc847 100644
--- a/src/pxar/extract.rs
+++ b/src/pxar/extract.rs
@@ -24,6 +24,8 @@ use crate::pxar::dir_stack::PxarDirStack;
 use crate::pxar::metadata;
 use crate::pxar::Flags;
 
+pub type ErrorHandler = Box<dyn FnMut(Error) -> Result<(), Error> + Send>;
+
 pub fn extract_archive<T, F>(
     mut decoder: pxar::decoder::Decoder<T>,
     destination: &Path,
@@ -32,7 +34,7 @@ pub fn extract_archive<T, F>(
     feature_flags: Flags,
     allow_existing_dirs: bool,
     mut callback: F,
-    on_error: Option<Box<dyn FnMut(Error) -> Result<(), Error> + Send>>,
+    on_error: Option<ErrorHandler>,
 ) -> Result<(), Error>
 where
     T: pxar::decoder::SeqRead,
@@ -212,7 +214,7 @@ pub(crate) struct Extractor {
 
     /// Error callback. Includes `current_path` in the reformatted error, should return `Ok` to
     /// continue extracting or the passed error as `Err` to bail out.
-    on_error: Box<dyn FnMut(Error) -> Result<(), Error> + Send>,
+    on_error: ErrorHandler,
 }
 
 impl Extractor {
diff --git a/src/pxar/mod.rs b/src/pxar/mod.rs
index 6e910667..82998cf8 100644
--- a/src/pxar/mod.rs
+++ b/src/pxar/mod.rs
@@ -59,7 +59,7 @@ mod flags;
 pub use flags::Flags;
 
 pub use create::create_archive;
-pub use extract::extract_archive;
+pub use extract::{extract_archive, ErrorHandler};
 
 /// The format requires to build sorted directory lookup tables in
 /// memory, so we restrict the number of allowed entries to limit
-- 
2.20.1






More information about the pbs-devel mailing list