Struct archive_reader::Archive

source ·
pub struct Archive { /* private fields */ }
Expand description

Archive represents an archive file which can be processed.

Implementations§

source§

impl Archive

source

pub fn open<P: AsRef<Path>>(path: P) -> Self

open creates a default Archive configuration from the given path.

Note:

It handles the path lazily. So no error will occur until the path is used and proved to be problematic.

source

pub fn block_size(&mut self, block_size: usize) -> &mut Self

block_size sets the size limit for every block reading from the archive. The block size is represented in bytes.

Note:

Content from archives are read block by block. Setting the block size will increase/decrease the time and content of reading each block.

source

pub fn reset_block_size(&mut self) -> &mut Self

reset_block_size resets the block size back to the default value (1024 * 1024).

source

pub fn decoder( &mut self, function: fn(_: &[u8]) -> Option<Cow<'_, str>> ) -> &mut Self

decoding_fn sets a function as the decoder.

Note:

A decoder is a function that converts a series of bytes into a proper string. In the case where the conversion failed, it should return None.

source

pub fn reset_decoder(&mut self) -> &mut Self

reset_decoder resets the decoder back to the default decoder. The default decoder converts the bytes into an UTF-8 encoded string. Any inconvertible characters will be replaced with a U+FFFD REPLACEMENT CHARACTER, which looks like this: �.

source§

impl Archive

source

pub fn list_file_names( &self ) -> Result<impl Iterator<Item = Result<String>> + Send>

list_file_names return an iterator of file names extracted from the archive. The file names are decoded using the decoder.

source

pub fn read_file<W: Write>(&self, file_name: &str, output: W) -> Result<usize>

read_file reads the content of a file into the given output. It also returns the total number of bytes read.

source

pub fn read_file_by_block( &self, file_name: &str ) -> Result<impl Iterator<Item = Result<Box<[u8]>>> + Send>

read_file_by_block reads the content of a file, and returns an iterator of the blocks.

source

pub fn entries(&self) -> Result<impl Iterator<Item = Result<Entry>> + Send>

entries returns an iterator of Entrys. Each Entry represents a file / dir in an archive. Using the functions provided on the Entry object, one can obtain two things from each entry:

  1. name
  2. content
source§

impl Archive

source

pub fn path(&self) -> &Path

path returns the archive file path.

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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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.
const: unstable · 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.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.