Skip to main content

EntrySeekableWriter

Struct EntrySeekableWriter 

Source
pub struct EntrySeekableWriter<'b, W: AsyncWrite + AsyncSeek + Unpin> { /* private fields */ }
Expand description

An entry writer which streams data to a seekable ZIP output.

Unlike EntryStreamWriter, this writer doesn’t use data descriptors. Instead, it writes a placeholder local file header, streams the entry data, then seeks back and patches the header with the final CRC and sizes.

If the final compressed or uncompressed size requires Zip64 but no Zip64 size fields were reserved up front, closing this writer will fail. Use ZipEntryBuilder::size to reserve those fields when the size is known to exceed the non-Zip64 limit, or use ZipFileWriter::write_entry_stream for fully unknown Zip64-sized entries.

Implementations§

Source§

impl<'b, W: AsyncWrite + AsyncSeek + Unpin> EntrySeekableWriter<'b, W>

Source

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

Consumes this entry writer and completes all closing tasks.

This includes:

  • Finalising the CRC32 hash value for the written data.
  • Calculating the compressed and uncompressed byte sizes.
  • Seeking back to patch the local file header.
  • Constructing a central directory header.
  • Pushing that central directory header to the ZipFileWriter’s store.

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

Trait Implementations§

Source§

impl<'a, W: AsyncWrite + AsyncSeek + Unpin> AsyncWrite for EntrySeekableWriter<'a, W>

Source§

fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize, Error>>

Attempt to write bytes from buf into the object. Read more
Source§

fn poll_flush( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<(), Error>>

Attempt to flush the object, ensuring that any buffered data reach their destination. Read more
Source§

fn poll_close( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<(), Error>>

Attempt to close the object. Read more
Source§

fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>], ) -> Poll<Result<usize, Error>>

Attempt to write bytes from bufs into the object using vectored IO operations. Read more

Auto Trait Implementations§

§

impl<'b, W> Freeze for EntrySeekableWriter<'b, W>

§

impl<'b, W> RefUnwindSafe for EntrySeekableWriter<'b, W>
where W: RefUnwindSafe,

§

impl<'b, W> Send for EntrySeekableWriter<'b, W>
where W: Send,

§

impl<'b, W> Sync for EntrySeekableWriter<'b, W>
where W: Sync,

§

impl<'b, W> Unpin for EntrySeekableWriter<'b, W>

§

impl<'b, W> UnsafeUnpin for EntrySeekableWriter<'b, W>

§

impl<'b, W> !UnwindSafe for EntrySeekableWriter<'b, W>

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<W> AsyncWriteExt for W
where W: AsyncWrite + ?Sized,

Source§

fn write<'a>(&'a mut self, buf: &'a [u8]) -> WriteFuture<'a, Self>
where Self: Unpin,

Writes some bytes into the byte stream. Read more
Source§

fn write_vectored<'a>( &'a mut self, bufs: &'a [IoSlice<'a>], ) -> WriteVectoredFuture<'a, Self>
where Self: Unpin,

Like write(), except that it writes a slice of buffers. Read more
Source§

fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> WriteAllFuture<'a, Self>
where Self: Unpin,

Writes an entire buffer into the byte stream. Read more
Source§

fn flush(&mut self) -> FlushFuture<'_, Self>
where Self: Unpin,

Flushes the stream to ensure that all buffered contents reach their destination. Read more
Source§

fn close(&mut self) -> CloseFuture<'_, Self>
where Self: Unpin,

Closes the writer. Read more
Source§

fn boxed_writer<'a>(self) -> Pin<Box<dyn AsyncWrite + Send + 'a>>
where Self: Sized + Send + 'a,

Available on crate feature alloc only.
Boxes the writer and changes its type to dyn AsyncWrite + Send + 'a. 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> FuturesAsyncWriteCompatExt for T
where T: AsyncWrite,

Source§

fn compat_write(self) -> Compat<Self>
where Self: Sized,

Wraps self with a compatibility layer that implements tokio::io::AsyncWrite.
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.