pub struct ArchiveReader<R: Read + Seek> { /* private fields */ }
Expand description
Reads a 7z archive file.
Implementations§
Source§impl ArchiveReader<File>
impl ArchiveReader<File>
Source§impl<R: Read + Seek> ArchiveReader<R>
impl<R: Read + Seek> ArchiveReader<R>
Sourcepub fn new(source: R, password: Password) -> Result<Self, Error>
pub fn new(source: R, password: Password) -> Result<Self, Error>
Creates a ArchiveReader
to read a 7z archive file from the given source
reader.
Sourcepub fn from_archive(archive: Archive, source: R, password: Password) -> Self
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 instancesource
- The reader providing access to the archive datapassword
- Password for encrypted archives
Sourcepub fn set_thread_count(&mut self, thread_count: u32)
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.
Sourcepub fn archive(&self) -> &Archive
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.
Sourcepub fn for_each_entries<F: FnMut(&ArchiveEntry, &mut dyn Read) -> Result<bool, Error>>(
&mut self,
each: F,
) -> Result<(), Error>
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.
Sourcepub fn read_file(&mut self, name: &str) -> Result<Vec<u8>, Error>
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.
Sourcepub fn file_compression_methods(
&self,
file_name: &str,
methods: &mut Vec<EncoderMethod>,
) -> Result<(), Error>
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.