Skip to main content

verify_reader_with_progress

Function verify_reader_with_progress 

Source
pub fn verify_reader_with_progress(
    reader: ArchiveReader<'_>,
    config: &SecurityConfig,
    options: &VerificationOptions,
    progress: &mut dyn ProgressCallback,
) -> Result<VerificationReport>
Expand description

Verifies an archive read from a reader, reporting progress.

verify_reader with a ProgressCallback, which sees the events of verify_archive_with_progress: one on_entry_start / on_entry_complete pair per scanned entry, and on_complete once when a report is returned, including one whose status is Fail.

§Errors

Same as verify_reader. on_complete is not called on failure.

§Examples

use exarch_core::ArchiveReader;
use exarch_core::NoopProgress;
use exarch_core::SecurityConfig;
use exarch_core::VerificationOptions;
use exarch_core::VerificationStatus;
use exarch_core::verify_reader_with_progress;

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 report = verify_reader_with_progress(
    reader,
    &SecurityConfig::default(),
    &VerificationOptions::default(),
    &mut NoopProgress,
)?;
assert_eq!(report.status(), VerificationStatus::Pass);