[−][src]Struct zip::write::ZipWriter
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][−]
ⓘImportant traits for ZipWriter<W>pub fn new(inner: W) -> ZipWriter<W>
[src][−]
ⓘImportant traits for ZipWriter<W>
Initializes the ZipWriter.
Before writing to this object, the start_file command should be called.
pub fn start_file<S>(&mut self, name: S, options: FileOptions) -> ZipResult<()> where
S: Into<String>,
[src][−]
S: Into<String>,
Starts a file.
pub fn add_directory<S>(
&mut self,
name: S,
options: FileOptions
) -> ZipResult<()> where
S: Into<String>,
[src][−]
&mut self,
name: S,
options: FileOptions
) -> ZipResult<()> where
S: Into<String>,
Add a directory entry.
You should not write data to the file afterwards.
pub fn finish(&mut self) -> ZipResult<W>
[src][−]
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> Drop for ZipWriter<W>
[src][+]
impl<W: Write + Seek> Write for ZipWriter<W>
[src][+]
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src][−]
impl<T, U> Into for T where
U: From<T>,
[src][−]
U: From<T>,
impl<T, U> TryFrom for T where
T: From<U>,
[src][−]
T: From<U>,
type Error = !
🔬 This is a nightly-only experimental API. (
try_from
)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> Borrow for T where
T: ?Sized,
[src][−]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src][−]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src][−]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src][−]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src][−]
impl<T> Any for T where
T: 'static + ?Sized,
[src][−]
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src][−]
impl<W> WritePodExt for W where
W: Write,
[src][−]
W: Write,
fn write_u64<T>(&mut self, val: u64) -> Result<(), Error> where
T: Endianness,
[src][−]
T: Endianness,
fn write_u32<T>(&mut self, val: u32) -> Result<(), Error> where
T: Endianness,
[src][−]
T: Endianness,
fn write_u16<T>(&mut self, val: u16) -> Result<(), Error> where
T: Endianness,
[src][−]
T: Endianness,
fn write_u8(&mut self, val: u8) -> Result<(), Error>
[src][−]
fn write_i64<T>(&mut self, val: i64) -> Result<(), Error> where
T: Endianness,
[src][−]
T: Endianness,
fn write_i32<T>(&mut self, val: i32) -> Result<(), Error> where
T: Endianness,
[src][−]
T: Endianness,
fn write_i16<T>(&mut self, val: i16) -> Result<(), Error> where
T: Endianness,
[src][−]
T: Endianness,
fn write_i8(&mut self, val: i8) -> Result<(), Error>
[src][−]
fn write_f32<T>(&mut self, val: f32) -> Result<(), Error> where
T: Endianness,
[src][−]
T: Endianness,
fn write_f64<T>(&mut self, val: f64) -> Result<(), Error> where
T: Endianness,
[src][−]
T: Endianness,