Struct zip::read::ZipArchive [−][src]
ZIP archive reader
use std::io::prelude::*; fn list_zip_contents(reader: impl Read + Seek) -> zip::result::ZipResult<()> { let mut zip = zip::ZipArchive::new(reader)?; for i in 0..zip.len() { let mut file = zip.by_index(i)?; println!("Filename: {}", file.name()); std::io::copy(&mut file, &mut std::io::stdout()); } Ok(()) }
Implementations
impl<R: Read + Seek> ZipArchive<R>
[src]
pub fn new(reader: R) -> ZipResult<ZipArchive<R>>
[src]
Read a ZIP archive, collecting the files it contains
This uses the central directory record of the ZIP file, and ignores local file headers
pub fn extract<P: AsRef<Path>>(&mut self, directory: P) -> ZipResult<()>
[src]
Extract a Zip archive into a directory, overwriting files if they
already exist. Paths are sanitized with ZipFile::enclosed_name
.
Extraction is not atomic; If an error is encountered, some of the files may be left on disk.
pub fn len(&self) -> usize
[src]
Number of files contained in this zip.
pub fn is_empty(&self) -> bool
[src]
Whether this zip archive contains no files
pub fn offset(&self) -> u64
[src]
Get the offset from the beginning of the underlying reader that this zip begins at, in bytes.
Normally this value is zero, but if the zip has arbitrary data prepended to it, then this value will be the size of that prepended data.
pub fn comment(&self) -> &[u8]
[src]
Get the comment of the zip archive.
pub fn file_names(&self) -> impl Iterator<Item = &str>
[src]
Returns an iterator over all the file and directory names in this archive.
pub fn by_name_decrypt<'a>(
&'a mut self,
name: &str,
password: &[u8]
) -> ZipResult<Result<ZipFile<'a>, InvalidPassword>>
[src]
&'a mut self,
name: &str,
password: &[u8]
) -> ZipResult<Result<ZipFile<'a>, InvalidPassword>>
Search for a file entry by name, decrypt with given password
pub fn by_name<'a>(&'a mut self, name: &str) -> ZipResult<ZipFile<'a>>
[src]
Search for a file entry by name
pub fn by_index_decrypt<'a>(
&'a mut self,
file_number: usize,
password: &[u8]
) -> ZipResult<Result<ZipFile<'a>, InvalidPassword>>
[src]
&'a mut self,
file_number: usize,
password: &[u8]
) -> ZipResult<Result<ZipFile<'a>, InvalidPassword>>
Get a contained file by index, decrypt with given password
pub fn by_index<'a>(&'a mut self, file_number: usize) -> ZipResult<ZipFile<'a>>
[src]
Get a contained file by index
pub fn by_index_raw<'a>(
&'a mut self,
file_number: usize
) -> ZipResult<ZipFile<'a>>
[src]
&'a mut self,
file_number: usize
) -> ZipResult<ZipFile<'a>>
Get a contained file by index without decompressing it
pub fn into_inner(self) -> R
[src]
Unwrap and return the inner reader object
The position of the reader is undefined.
Trait Implementations
impl<R: Clone + Read + Seek> Clone for ZipArchive<R>
[src]
fn clone(&self) -> ZipArchive<R>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<R: Debug + Read + Seek> Debug for ZipArchive<R>
[src]
Auto Trait Implementations
impl<R> RefUnwindSafe for ZipArchive<R> where
R: RefUnwindSafe,
[src]
R: RefUnwindSafe,
impl<R> Send for ZipArchive<R> where
R: Send,
[src]
R: Send,
impl<R> Sync for ZipArchive<R> where
R: Sync,
[src]
R: Sync,
impl<R> Unpin for ZipArchive<R> where
R: Unpin,
[src]
R: Unpin,
impl<R> UnwindSafe for ZipArchive<R> where
R: UnwindSafe,
[src]
R: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,