pub struct ExtractRequest<'a> { /* private fields */ }Expand description
Extracts an archive into a directory.
Holds the SecurityConfig the extraction runs under, the
ExtractionOptions and an optional ProgressCallback. Every entry
passes the validation pipeline before it is written.
§Errors
extract returns an error if:
- the archive cannot be opened
- the archive format is unsupported
- security validation fails
- an I/O operation fails
- the atomic staging directory cannot be created or renamed into place
§Examples
use exarch_core::ExtractRequest;
use exarch_core::ExtractionOptions;
use exarch_core::NoopProgress;
use exarch_core::SecurityConfig;
let config = SecurityConfig::default();
let mut progress = NoopProgress;
let report = ExtractRequest::new(&config)
.with_options(ExtractionOptions::default().with_atomic(true))
.with_progress(&mut progress)
.extract("archive.tar.gz", "/tmp/output")?;
println!("Extracted {} files", report.files_extracted);Implementations§
Source§impl<'a> ExtractRequest<'a>
impl<'a> ExtractRequest<'a>
Sourcepub fn new(config: &'a SecurityConfig) -> Self
pub fn new(config: &'a SecurityConfig) -> Self
An extraction under config with default options and no progress
callback.
Sourcepub fn with_options(self, options: ExtractionOptions) -> Self
pub fn with_options(self, options: ExtractionOptions) -> Self
Sets the extraction options.
Sourcepub fn with_progress(self, progress: &'a mut dyn ProgressCallback) -> Self
pub fn with_progress(self, progress: &'a mut dyn ProgressCallback) -> Self
Reports progress to progress.
Trait Implementations§
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for ExtractRequest<'a>
impl<'a> !Sync for ExtractRequest<'a>
impl<'a> !UnwindSafe for ExtractRequest<'a>
impl<'a> Freeze for ExtractRequest<'a>
impl<'a> Send for ExtractRequest<'a>
impl<'a> Unpin for ExtractRequest<'a>
impl<'a> UnsafeUnpin for ExtractRequest<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more