pub struct TarballReader<'c> {
archive: Archive<CompressionDecoder<'c>>,
}
Expand description
A generic tarball reader that can be used to read both compressed tarballs
.tar.*
and uncompressed tar archives .tar
.
Can be created from a Path
or PathBuf
,
which will automatically detect the optional compression algorithm based on the file extension.
§Note
The lifetime 'c
is for CompressionDecoder
of the underlying Archive
.
Fields§
§archive: Archive<CompressionDecoder<'c>>
Implementations§
Source§impl<'c> TarballReader<'c>
impl<'c> TarballReader<'c>
Sourcepub fn new(decoder: CompressionDecoder<'c>) -> Self
pub fn new(decoder: CompressionDecoder<'c>) -> Self
Creates a new TarballReader
that reads from a CompressionDecoder
.
Sourcepub fn entries<'a>(&'a mut self) -> Result<TarballEntries<'a, 'c>, Error>
pub fn entries<'a>(&'a mut self) -> Result<TarballEntries<'a, 'c>, Error>
Returns an iterator over the entries in the tarball.
§Errors
Returns an error if Archive::entries
fails.
Sourcepub fn read_entry<'a, P: AsRef<Path>>(
&'a mut self,
path: P,
) -> Result<Option<TarballEntry<'a, 'c>>, Error>
pub fn read_entry<'a, P: AsRef<Path>>( &'a mut self, path: P, ) -> Result<Option<TarballEntry<'a, 'c>>, Error>
Reads a specific TarballEntry
by its path.
Returns None
if the entry does not exist.
§Errors
Returns an error if Self::entries
or reading an entry fails.
Trait Implementations§
Source§impl Debug for TarballReader<'_>
impl Debug for TarballReader<'_>
Source§impl TryFrom<&Path> for TarballReader<'_>
impl TryFrom<&Path> for TarballReader<'_>
Source§fn try_from(path: &Path) -> Result<Self, Self::Error>
fn try_from(path: &Path) -> Result<Self, Self::Error>
Creates a new TarballReader
from a Path
.
§Errors
Returns an error if
- the file at
path
cannot be opened for reading, - the file extension is neither a
.tar
nor an extension of a supported compression algorithm, - a
CompressionDecoder
cannot be created from the file andDecompressionSettings
.
Source§impl TryFrom<PathBuf> for TarballReader<'_>
impl TryFrom<PathBuf> for TarballReader<'_>
Auto Trait Implementations§
impl<'c> !Freeze for TarballReader<'c>
impl<'c> !RefUnwindSafe for TarballReader<'c>
impl<'c> Send for TarballReader<'c>
impl<'c> !Sync for TarballReader<'c>
impl<'c> Unpin for TarballReader<'c>
impl<'c> !UnwindSafe for TarballReader<'c>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more