[−][src]Struct zip::read::ZipArchive
Wrapper for reading the contents of a ZIP file.
fn doit() -> zip::result::ZipResult<()> { use std::io::prelude::*; // For demonstration purposes we read from an empty buffer. // Normally a File object would be used. let buf: &[u8] = &[0u8; 128]; let mut reader = std::io::Cursor::new(buf); let mut zip = zip::ZipArchive::new(reader)?; for i in 0..zip.len() { let mut file = zip.by_index(i).unwrap(); println!("Filename: {}", file.name()); let first_byte = file.bytes().next().unwrap()?; println!("{}", first_byte); } Ok(()) } println!("Result: {:?}", doit());
Methods
impl<R: Read + Seek> ZipArchive<R>
[src]
pub fn new(reader: R) -> ZipResult<ZipArchive<R>>
[src]
Opens a Zip archive and parses the central directory
pub fn len(&self) -> usize
[src]
Number of files contained in this zip.
fn iter() { let mut zip = zip::ZipArchive::new(std::io::Cursor::new(vec![])).unwrap(); for i in 0..zip.len() { let mut file = zip.by_index(i).unwrap(); // Do something with file i } }
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 by_name<'a>(&'a mut self, name: &str) -> ZipResult<ZipFile<'a>>
[src]
Search for a file entry by name
pub fn by_index<'a>(&'a mut self, file_number: usize) -> ZipResult<ZipFile<'a>>
[src]
Get a contained file by index
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]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<R: Debug + Read + Seek> Debug for ZipArchive<R>
[src]
Auto Trait Implementations
impl<R> Unpin for ZipArchive<R> where
R: Unpin,
R: Unpin,
impl<R> Sync for ZipArchive<R> where
R: Sync,
R: Sync,
impl<R> Send for ZipArchive<R> where
R: Send,
R: Send,
impl<R> UnwindSafe for ZipArchive<R> where
R: UnwindSafe,
R: UnwindSafe,
impl<R> RefUnwindSafe for ZipArchive<R> where
R: RefUnwindSafe,
R: RefUnwindSafe,
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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.
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,