Skip to main content

list_reader

Function list_reader 

Source
pub fn list_reader(
    reader: ArchiveReader<'_>,
    config: &SecurityConfig,
    options: &ListOptions,
) -> Result<ArchiveManifest>
Expand description

Lists the contents of an archive read from a reader.

The reader counterpart of list_archive_with_options: the same listing, limits and failures, for an archive that is not a file on disk.

§Errors

Same as list_archive, except that nothing is opened or detected: a malformed archive fails as it would from a file.

§Examples

use exarch_core::ArchiveReader;
use exarch_core::ListOptions;
use exarch_core::SecurityConfig;
use exarch_core::list_reader;

let mut builder = tar::Builder::new(Vec::new());
let mut header = tar::Header::new_gnu();
header.set_size(2);
header.set_mode(0o644);
builder.append_data(&mut header, "a.txt", &b"hi"[..])?;
let bytes = builder.into_inner()?;

let reader = ArchiveReader::tar(std::io::Cursor::new(bytes), None);
let manifest = list_reader(reader, &SecurityConfig::default(), &ListOptions::default())?;
assert_eq!(manifest.total_entries(), 1);