Struct zip::read::ZipArchive
[−]
[src]
pub struct ZipArchive<R: Read + Seek> { // some fields omitted }
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 = try!(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 = try!(file.bytes().next().unwrap()); println!("{}", first_byte); } Ok(()) } println!("Result: {:?}", doit());
Methods
impl<R: Read + Seek> ZipArchive<R>
[src]
fn new(reader: R) -> ZipResult<ZipArchive<R>>
Opens a Zip archive and parses the central directory
fn len(&self) -> usize
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 } }
fn by_name<'a>(&'a mut self, name: &str) -> ZipResult<ZipFile<'a>>
Search for a file entry by name
fn by_index<'a>(&'a mut self, file_number: usize) -> ZipResult<ZipFile<'a>>
Get a contained file by index
fn into_inner(self) -> R
Unwrap and return the inner reader object
The position of the reader is undefined.