Struct zip::write::ZipWriter
[−]
[src]
pub struct ZipWriter<W: Write + Seek> { /* fields omitted */ }
Generator for ZIP files.
fn doit() -> zip::result::ZipResult<()> { use std::io::Write; // For this example we write to a buffer, but normally you should use a File let mut buf: &mut [u8] = &mut [0u8; 65536]; let mut w = std::io::Cursor::new(buf); let mut zip = zip::ZipWriter::new(w); let options = zip::write::FileOptions::default().compression_method(zip::CompressionMethod::Stored); try!(zip.start_file("hello_world.txt", options)); try!(zip.write(b"Hello, World!")); // Optionally finish the zip. (this is also done on drop) try!(zip.finish()); Ok(()) } println!("Result: {:?}", doit().unwrap());
Methods
impl<W: Write + Seek> ZipWriter<W>
[src]
fn new(inner: W) -> ZipWriter<W>
Initializes the ZipWriter.
Before writing to this object, the start_file command should be called.
fn start_file<S>(&mut self, name: S, options: FileOptions) -> ZipResult<()> where
S: Into<String>,
S: Into<String>,
Starts a file.
fn add_directory<S>(&mut self, name: S, options: FileOptions) -> ZipResult<()> where
S: Into<String>,
S: Into<String>,
Add a directory entry.
You should not write data to the file afterwards.
fn finish(&mut self) -> ZipResult<W>
Finish the last file and write all other zip-structures
This will return the writer, but one should normally not append any data to the end of the file. Note that the zipfile will also be finished on drop.
Trait Implementations
impl<W: Write + Seek> Write for ZipWriter<W>
[src]
fn write(&mut self, buf: &[u8]) -> Result<usize>
Write a buffer into this object, returning how many bytes were written. Read more
fn flush(&mut self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0
Attempts to write an entire buffer into this write. Read more
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
1.0.0
Writes a formatted string into this writer, returning any error encountered. Read more
fn by_ref(&mut self) -> &mut Self
1.0.0
Creates a "by reference" adaptor for this instance of Write
. Read more