ArchiveReader

Struct ArchiveReader 

Source
pub struct ArchiveReader<R: Read + Seek> { /* private fields */ }
Expand description

Reads a 7z archive file.

Implementations§

Source§

impl ArchiveReader<File>

Source

pub fn open(path: impl AsRef<Path>, password: Password) -> Result<Self, Error>

Available on non-WebAssembly only.

Opens a 7z archive file at the given path and creates a ArchiveReader to read it.

Source§

impl<R: Read + Seek> ArchiveReader<R>

Source

pub fn new(source: R, password: Password) -> Result<Self, Error>

Creates a ArchiveReader to read a 7z archive file from the given source reader.

Source

pub fn from_archive(archive: Archive, source: R, password: Password) -> Self

Creates an ArchiveReader from an existing Archive instance.

This is useful when you already have a parsed archive and want to create a reader without re-parsing the archive structure.

§Arguments
  • archive - An existing parsed archive instance
  • source - The reader providing access to the archive data
  • password - Password for encrypted archives
Source

pub fn set_thread_count(&mut self, thread_count: u32)

Sets the thread count to use when multi-threading is supported by the de-compression (currently only LZMA2 if encoded with MT support).

Defaults to std::thread::available_parallelism() if not set manually.

Source

pub fn archive(&self) -> &Archive

Returns a reference to the underlying Archive structure.

This provides access to the archive metadata including files, blocks, and compression information.

Source

pub fn for_each_entries<F: FnMut(&ArchiveEntry, &mut dyn Read) -> Result<bool, Error>>( &mut self, each: F, ) -> Result<(), Error>

Takes a closure to decode each files in the archive.

Attention about solid archive: When decoding a solid archive, the data to be decompressed depends on the data in front of it, you cannot simply skip the previous data and only decompress the data in the back.

Source

pub fn read_file(&mut self, name: &str) -> Result<Vec<u8>, Error>

Returns the data of a file with the given path inside the archive.

§Notice

This function is very inefficient when used with solid archives, since it needs to decode all data before the actual file.

Source

pub fn file_compression_methods( &self, file_name: &str, methods: &mut Vec<EncoderMethod>, ) -> Result<(), Error>

Get the compression method(s) used for a specific file in the archive.

Auto Trait Implementations§

§

impl<R> Freeze for ArchiveReader<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for ArchiveReader<R>
where R: RefUnwindSafe,

§

impl<R> Send for ArchiveReader<R>
where R: Send,

§

impl<R> Sync for ArchiveReader<R>
where R: Sync,

§

impl<R> Unpin for ArchiveReader<R>
where R: Unpin,

§

impl<R> UnwindSafe for ArchiveReader<R>
where R: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.