Skip to main content

ZipFileWriter

Struct ZipFileWriter 

Source
pub struct ZipFileWriter<W> { /* private fields */ }
Expand description

A ZIP file writer which acts over AsyncWrite implementers.

§Note

Implementations§

Source§

impl<W: AsyncWrite + Unpin> ZipFileWriter<W>

Source

pub fn new(writer: W) -> Self

Construct a new ZIP file writer from a mutable reference to a writer.

Source

pub fn force_no_zip64(self) -> Self

Force the ZIP writer to operate in non-ZIP64 mode. If any files would need ZIP64, an error will be raised.

Source

pub fn force_zip64(self) -> Self

Force the ZIP writer to emit Zip64 structs at the end of the archive. Zip64 extended fields will only be written if needed.

Source

pub async fn write_entry_whole<E: Into<ZipEntry>>( &mut self, entry: E, data: &[u8], ) -> Result<()>

Write a new ZIP entry of known size and data.

Source

pub async fn write_entry_stream<E: Into<ZipEntry>>( &mut self, entry: E, ) -> Result<EntryStreamWriter<'_, W>>

Write an entry of unknown size and data via streaming (ie. using a data descriptor). The generated Local File Header will be invalid, with no compressed size, uncompressed size, and a null CRC. This might cause problems with the destination reader.

Source

pub async fn write_entry_seekable<E: Into<ZipEntry>>( &mut self, entry: E, ) -> Result<EntrySeekableWriter<'_, W>>
where W: AsyncSeek,

Write an entry of unknown size and data via streaming to a seekable output.

This avoids data descriptors by seeking back to patch the local file header after the entry is written.

Source

pub fn comment(&mut self, comment: String)

Set the ZIP file comment.

Source

pub fn inner_mut(&mut self) -> &mut W

Returns a mutable reference to the inner writer.

Care should be taken when using this inner writer as doing so may invalidate internal state of this writer.

Source

pub async fn close(self) -> Result<W>

Consumes this ZIP writer and completes all closing tasks.

This includes:

  • Writing all central directory headers.
  • Writing the end of central directory header.
  • Writing the file comment.

Failure to call this function before going out of scope would result in a corrupted ZIP file.

Source§

impl<W> ZipFileWriter<Compat<W>>
where W: AsyncWrite + Unpin,

Source

pub fn with_tokio(writer: W) -> TokioZipFileWriter<W>

Available on crate feature tokio only.

Construct a new ZIP file writer from a mutable reference to a writer.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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

§

impl<W> UnwindSafe for ZipFileWriter<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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.