BytesBufVectoredWrite

Struct BytesBufVectoredWrite 

Source
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<'_>

Source

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.

Source

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).

Source

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.

Trait Implementations§

Source§

impl<'a> Debug for BytesBufVectoredWrite<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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.