Skip to main content

StoredZipWriter

Struct StoredZipWriter 

Source
pub struct StoredZipWriter<W: Write> { /* private fields */ }
Expand description

Writes a stored ZIP archive to W. Add entries, then finish. Nothing is flushed or synced: wrap a file in [crate::AtomicWriter] (or write the finished bytes with [crate::atomic_write]) when the archive must appear whole.

Implementations§

Source§

impl<W: Write> StoredZipWriter<W>

Source

pub fn new(out: W) -> Self

A writer that appends to out from its current position (the archive starts there).

Source

pub fn add_file(&mut self, name: &str, data: &[u8]) -> Result<()>

Add a file entry holding data.

Errors (InvalidInput): a bad or duplicate name, data of 4 GiB or more, an archive past the ZIP limits, or a local-header offset past 4 GiB. A failed write is the writer’s error.

Source

pub fn add_dir(&mut self, name: &str) -> Result<()>

Add a directory entry (name with or without a trailing /; the stored name ends in /).

Source

pub fn finish(self) -> Result<W>

Write the central directory and end record and return the underlying writer. The archive is complete only after this succeeds.

Auto Trait Implementations§

§

impl<W> Freeze for StoredZipWriter<W>
where W: Freeze,

§

impl<W> RefUnwindSafe for StoredZipWriter<W>
where W: RefUnwindSafe,

§

impl<W> Send for StoredZipWriter<W>
where W: Send,

§

impl<W> Sync for StoredZipWriter<W>
where W: Sync,

§

impl<W> Unpin for StoredZipWriter<W>
where W: Unpin,

§

impl<W> UnsafeUnpin for StoredZipWriter<W>
where W: UnsafeUnpin,

§

impl<W> UnwindSafe for StoredZipWriter<W>
where W: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.