pub struct ZipFileWriter<W> { /* private fields */ }Expand description
A ZIP file writer which acts over AsyncWrite implementers.
§Note
ZipFileWriter::close()must be called before a stream writer goes out of scope.
Implementations§
Source§impl<W: AsyncWrite + Unpin> ZipFileWriter<W>
impl<W: AsyncWrite + Unpin> ZipFileWriter<W>
Sourcepub fn new(writer: W) -> Self
pub fn new(writer: W) -> Self
Construct a new ZIP file writer from a mutable reference to a writer.
Sourcepub fn force_no_zip64(self) -> Self
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.
Sourcepub fn force_zip64(self) -> Self
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.
Sourcepub async fn write_entry_whole<E: Into<ZipEntry>>(
&mut self,
entry: E,
data: &[u8],
) -> Result<()>
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.
Sourcepub async fn write_entry_stream<E: Into<ZipEntry>>(
&mut self,
entry: E,
) -> Result<EntryStreamWriter<'_, W>>
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.
Sourcepub async fn write_entry_seekable<E: Into<ZipEntry>>(
&mut self,
entry: E,
) -> Result<EntrySeekableWriter<'_, W>>where
W: AsyncSeek,
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.
Sourcepub fn inner_mut(&mut self) -> &mut W
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.
Sourcepub async fn close(self) -> Result<W>
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,
impl<W> ZipFileWriter<Compat<W>>where
W: AsyncWrite + Unpin,
Sourcepub fn with_tokio(writer: W) -> TokioZipFileWriter<W>
Available on crate feature tokio only.
pub fn with_tokio(writer: W) -> TokioZipFileWriter<W>
tokio only.Construct a new ZIP file writer from a mutable reference to a writer.