pub struct BytesBufVectoredWrite<'a> { /* private fields */ }Expand description
A vectored write is an operation that concurrently writes data into multiple chunks
of memory owned by a BytesBuf.
The operation takes exclusive ownership of the BytesBuf. During the vectored write,
the remaining capacity of the BytesBuf is exposed as MaybeUninit<u8> slices
that at the end of the operation must be filled sequentially and in order, without gaps,
in any desired amount (from 0 bytes written to all slices filled).
The capacity used during the operation can optionally be limited to max_len bytes.
The operation is completed by calling .commit() on the instance, after which the instance is
consumed and the exclusive ownership of the BytesBuf released.
If the type is dropped without committing, the operation is aborted and all remaining capacity is left in a potentially uninitialized state.
Implementations§
Source§impl BytesBufVectoredWrite<'_>
impl BytesBufVectoredWrite<'_>
Sourcepub fn iter_chunks_mut(&mut self) -> BytesBufAvailableIterator<'_> ⓘ
pub fn iter_chunks_mut(&mut self) -> BytesBufAvailableIterator<'_> ⓘ
Iterates over the chunks of available capacity in the sequence builder, allowing them to be filled with data.
Sourcepub fn extend_lifetime(&self) -> MemoryGuard
pub fn extend_lifetime(&self) -> MemoryGuard
Creates a memory guard that extends the lifetime of the memory blocks that provide the backing memory capacity for this sequence builder.
This can be useful when unsafe code is used to reference the contents of a BytesBuf
and it is possible to reach a condition where the BytesBuf itself no longer exists,
even though the contents are referenced (e.g. because this is happening in non-Rust code).
Sourcepub unsafe fn commit(self, bytes_written: usize)
pub unsafe fn commit(self, bytes_written: usize)
Completes the vectored write operation, committing bytes_written bytes of data that
sequentially and completely fills chunks from the start of the provided chunks.
§Safety
The caller must ensure that bytes_written bytes of data have actually been written
into the chunks of memory, sequentially from the start.