Struct piz::read::ZipArchive
source · [−]pub struct ZipArchive<'a> { /* private fields */ }
Expand description
A ZIP archive to be read
Implementations
sourceimpl<'a> ZipArchive<'a>
impl<'a> ZipArchive<'a>
sourcepub fn new(mapping: &'a [u8]) -> ZipResult<Self>
pub fn new(mapping: &'a [u8]) -> ZipResult<Self>
Reads a ZIP archive from a byte slice. Smaller files can be read into a buffer.
let bytes = fs::read("foo.zip")?;
let archive = ZipArchive::new(&bytes)?;
For larger ones, memory map!
let zip_file = File::open("foo.zip")?;
let mapping = unsafe { Mmap::map(&zip_file)? };
let archive = ZipArchive::new(&mapping)?;
sourcepub fn with_prepended_data(mapping: &'a [u8]) -> ZipResult<(Self, usize)>
pub fn with_prepended_data(mapping: &'a [u8]) -> ZipResult<(Self, usize)>
Like ZipArchive::new()
, but allows arbitrary data to prepend the archive.
Returns the ZipArchive and the number of bytes prepended to the archive.
Since a ZIP archive’s metadata sits at the back of the file, many formats consist of ZIP archives prepended with some other data. For example, a self-extracting archive is one with an executable in the front.
sourcepub fn entries(&self) -> &[FileMetadata<'_>]
pub fn entries(&self) -> &[FileMetadata<'_>]
Returns the entries found in the ZIP archive’s central directory.
No effort is made to deduplicate or otherwise validate these entries.
To do that, create a FileTree
.
Auto Trait Implementations
impl<'a> RefUnwindSafe for ZipArchive<'a>
impl<'a> Send for ZipArchive<'a>
impl<'a> Sync for ZipArchive<'a>
impl<'a> Unpin for ZipArchive<'a>
impl<'a> UnwindSafe for ZipArchive<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more