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>
impl<'a> ListRequest<'a>
Sourcepub fn new(config: &'a SecurityConfig) -> Self
pub fn new(config: &'a SecurityConfig) -> Self
A listing under config with default options and no progress callback.
Sourcepub const fn with_options(self, options: ListOptions) -> Self
pub const fn with_options(self, options: ListOptions) -> Self
Sets the listing 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.
Sourcepub fn list_reader(self, reader: ArchiveReader<'_>) -> Result<ArchiveManifest>
pub fn list_reader(self, reader: ArchiveReader<'_>) -> Result<ArchiveManifest>
Sourcepub fn for_extraction(
self,
archive: impl AsRef<Path>,
reuse: DecodeReuse,
) -> Result<ListedArchive>
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);