pub struct BytesBufVectoredWrite<'a> { /* private fields */ }Expand description
Coordinates concurrent write operations into a buffer’s memory capacity.
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).
All slices may be written to concurrently and/or in any order - consistency of the contents is only required at the moment the write is committed.
The capacity exposed during the operation can optionally be limited to max_len bytes.
The operation is completed by calling .commit() on the instance, after which the operation is
consumed and the exclusive ownership of the BytesBuf released.
If the instance 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_slices_mut(&mut self) -> BytesBufRemaining<'_> ⓘ
pub fn iter_slices_mut(&mut self) -> BytesBufRemaining<'_> ⓘ
Iterates over the slices of available capacity of the buffer, allowing them to be filled with data.
The slices returned from this iterator have the lifetime of the vectored write operation itself, allowing them to be mutated concurrently.
Sourcepub fn extend_lifetime(&self) -> MemoryGuard
pub fn extend_lifetime(&self) -> MemoryGuard
Extends the lifetime of the memory capacity backing this buffer.
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 the remaining references are 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 slices from the start of the provided slices.
§Safety
The caller must ensure that bytes_written bytes of data have actually been written
into the slices of memory returned from iter_slices_mut(), sequentially from the start.