Skip to main content

ExtractRequest

Struct ExtractRequest 

Source
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>

Source

pub fn new(config: &'a SecurityConfig) -> Self

An extraction under config with default options and no progress callback.

Source

pub fn with_options(self, options: ExtractionOptions) -> Self

Sets the extraction options.

Source

pub fn with_progress(self, progress: &'a mut dyn ProgressCallback) -> Self

Reports progress to progress.

Source

pub fn extract( self, archive: impl AsRef<Path>, output_dir: impl AsRef<Path>, ) -> Result<ExtractionReport>

Extracts archive into output_dir; the format is detected.

§Errors

See ExtractRequest.

Trait Implementations§

Source§

impl<'a> Debug for ExtractRequest<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.