pub struct ArchiveIteratorBuilder<R>{ /* private fields */ }Implementations§
Source§impl<R> ArchiveIteratorBuilder<R>
A builder to generate an archive iterator over the contents of an
archive, streaming the contents of each entry in small chunks.
The default configuration is identical to ArchiveIterator::from_read.
impl<R> ArchiveIteratorBuilder<R>
A builder to generate an archive iterator over the contents of an
archive, streaming the contents of each entry in small chunks.
The default configuration is identical to ArchiveIterator::from_read.
§Example
use compress_tools::{ArchiveContents, ArchiveIteratorBuilder};
use std::path::Path;
use std::ffi::OsStr;
let source = std::fs::File::open("tests/fixtures/tree.tar").expect("Failed to open file");
let decode_utf8 = |bytes: &[u8]| Ok(std::str::from_utf8(bytes)?.to_owned());
for content in ArchiveIteratorBuilder::new(source)
.decoder(decode_utf8)
.filter(|name, stat| Path::new(name).file_name() == Some(OsStr::new("foo")) || stat.st_size == 42)
.build()
.expect("Failed to initialize archive")
{
if let ArchiveContents::StartOfEntry(name, _stat) = content {
println!("{name}");
}
}Sourcepub fn new(source: R) -> ArchiveIteratorBuilder<R>
pub fn new(source: R) -> ArchiveIteratorBuilder<R>
Create a new builder for an archive iterator. Default configuration is
identical to ArchiveIterator::from_read.
Sourcepub fn decoder(self, decoder: DecodeCallback) -> ArchiveIteratorBuilder<R>
pub fn decoder(self, decoder: DecodeCallback) -> ArchiveIteratorBuilder<R>
Use a custom decoder to decode filenames of archive entries.
By default an UTF-8 decoder (decode_utf8) is used.
Sourcepub fn filter<F>(self, filter: F) -> ArchiveIteratorBuilder<R>
pub fn filter<F>(self, filter: F) -> ArchiveIteratorBuilder<R>
Use a filter to skip unwanted entries and their decompression. By default all entries are iterated.
Sourcepub fn with_password(
self,
password: ArchivePassword,
) -> ArchiveIteratorBuilder<R>
pub fn with_password( self, password: ArchivePassword, ) -> ArchiveIteratorBuilder<R>
Set a custom password to decode content of archive entries.
Sourcepub fn raw_format(self, enable: bool) -> ArchiveIteratorBuilder<R>
pub fn raw_format(self, enable: bool) -> ArchiveIteratorBuilder<R>
Enable libarchive’s “raw” format handler, which parses any byte
stream as a single-entry archive with pathname data.
Disabled by default so the iterator rejects input that isn’t a real archive. Enable it only when you intentionally want to iterate over arbitrary non-archive streams (e.g. a standalone gzip file).
Sourcepub fn mtree_format(self, enable: bool) -> ArchiveIteratorBuilder<R>
pub fn mtree_format(self, enable: bool) -> ArchiveIteratorBuilder<R>
Accept entries from libarchive’s “mtree” format handler (default).
libarchive’s mtree parser is permissive and will match free-form
text (a plain gunzip’d text file is enough); pass false to
reject those matches and error out instead.
Sourcepub fn build(self) -> Result<ArchiveIterator<R>>
pub fn build(self) -> Result<ArchiveIterator<R>>
Finish the builder and generate the configured ArchiveIterator.