Skip to main content

ListRequest

Struct ListRequest 

Source
pub struct ListRequest<'a> { /* private fields */ }
Expand description

Lists the contents of an archive without extracting it.

Holds the SecurityConfig whose quotas and path rules the listing enforces, the ListOptions and an optional ProgressCallback, which sees one on_entry_start / on_entry_complete pair per listed entry (total is unknown for TAR) and on_complete once after the manifest was built. Nothing is written to disk.

§Errors

list and list_reader return an error if:

  • the archive cannot be opened or its format is unsupported
  • the archive is corrupted
  • a quota is exceeded (file count, total size, single file size)
  • declared compressed sizes exceed the archive length

A reader source is neither opened nor detected, so a malformed archive fails as it would from a file. on_complete is not called on failure.

§Examples

use exarch_core::ListRequest;
use exarch_core::SecurityConfig;

let config = SecurityConfig::default();
let manifest = ListRequest::new(&config).list("archive.tar.gz")?;
println!("{} entries", manifest.total_entries());

Implementations§

Source§

impl<'a> ListRequest<'a>

Source

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

A listing under config with default options and no progress callback.

Source

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

Sets the listing options.

Source

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

Reports progress to progress.

Source

pub fn list(self, archive: impl AsRef<Path>) -> Result<ArchiveManifest>

Lists the archive file at archive.

§Errors

See ListRequest.

Source

pub fn list_reader(self, reader: ArchiveReader<'_>) -> Result<ArchiveManifest>

Lists an archive read from reader.

§Errors

See ListRequest.

Source

pub fn for_extraction( self, archive: impl AsRef<Path>, reuse: DecodeReuse, ) -> Result<ListedArchive>

Lists the archive at archive and keeps what extraction can reuse.

config is the policy the extraction will run under. The list pass itself runs under the same quotas, path rules, allowlist and decoder limits with the flags that only matter once bytes are written (symlinks, hardlinks, world-writable files, preserved permissions) turned off, so that a listing never admits more than the extraction would. The returned ListedArchive extracts under config, so what was listed is what is extracted.

reuse says where a ZIP archive keeps the output of its structural check for the extraction; for a compressed TAR the decoder output is spooled instead. See ListedArchive.

The progress callback, if any, sees the list pass’s entry events; on_complete is left to the extraction.

§Errors

See ListRequest.

§Examples
use exarch_core::DecodeReuse;
use exarch_core::ListRequest;
use exarch_core::SecurityConfig;

let config = SecurityConfig::default();
let listed = ListRequest::new(&config).for_extraction(&archive, DecodeReuse::default())?;
assert_eq!(listed.manifest().total_entries(), 1);

Trait Implementations§

Source§

impl<'a> Debug for ListRequest<'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 ListRequest<'a>

§

impl<'a> !Sync for ListRequest<'a>

§

impl<'a> !UnwindSafe for ListRequest<'a>

§

impl<'a> Freeze for ListRequest<'a>

§

impl<'a> Send for ListRequest<'a>

§

impl<'a> Unpin for ListRequest<'a>

§

impl<'a> UnsafeUnpin for ListRequest<'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.