pub struct ArchiveIteratorBuilder<R>where
    R: Read + Seek,{ /* private fields */ }

Implementations§

source§

impl<R> ArchiveIteratorBuilder<R>where R: Read + Seek,

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}");
        }
    }
source

pub fn new(source: R) -> ArchiveIteratorBuilder<R>

Create a new builder for an archive iterator. Default configuration is identical to ArchiveIterator::from_read.

source

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.

source

pub fn filter<F>(self, filter: F) -> ArchiveIteratorBuilder<R>where F: Fn(&str, &stat) -> bool + 'static,

Use a filter to skip unwanted entries and their decompression. By default all entries are iterated.

source

pub fn build(self) -> Result<ArchiveIterator<R>>

Finish the builder and generate the configured ArchiveIterator.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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.