pub trait IoBufMut: IoBuf + SetLen {
// Required method
fn as_uninit(&mut self) -> &mut [MaybeUninit<u8>];
// Provided methods
fn reserve(&mut self, len: usize) -> Result<(), ReserveError> { ... }
fn reserve_exact(&mut self, len: usize) -> Result<(), ReserveExactError> { ... }
}Expand description
A trait for mutable buffers.
The IoBufMut trait is implemented by buffer types that can be passed to
mutable completion-based IO operations, like reading content from a file and
write to the buffer. This trait will take all space of a buffer into
account, including uninitialized bytes.
Required Methods§
Sourcefn as_uninit(&mut self) -> &mut [MaybeUninit<u8>]
fn as_uninit(&mut self) -> &mut [MaybeUninit<u8>]
Get the full mutable slice of the buffer, including both initialized and uninitialized bytes.
Provided Methods§
Sourcefn reserve(&mut self, len: usize) -> Result<(), ReserveError>
fn reserve(&mut self, len: usize) -> Result<(), ReserveError>
Reserve additional capacity for the buffer.
By default, this checks if the spare capacity is enough to fit in
len-bytes. If it does, returns Ok(()), and otherwise returns
Err(ReserveError::NotSupported). Types that support dynamic
resizing (like Vec<u8>) will override this method to actually
reserve capacity. The return value indicates whether the reservation
succeeded. See ReserveError for details.
Notice that this may move the memory of the buffer, so it’s UB to call this after the buffer is being pinned.
Sourcefn reserve_exact(&mut self, len: usize) -> Result<(), ReserveExactError>
fn reserve_exact(&mut self, len: usize) -> Result<(), ReserveExactError>
Reserve exactly len additional capacity for the buffer.
By default this falls back to IoBufMut::reserve. Types that support
dynamic resizing (like Vec<u8>) will override this method to
actually reserve capacity. The return value indicates whether the
exact reservation succeeded. See ReserveExactError for details.
Notice that this may move the memory of the buffer, so it’s UB to call this after the buffer is being pinned.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<B> IoBufMut for &'static mut B
impl<B> IoBufMut for &'static mut B
fn as_uninit(&mut self) -> &mut [MaybeUninit<u8>]
fn reserve(&mut self, len: usize) -> Result<(), ReserveError>
fn reserve_exact(&mut self, len: usize) -> Result<(), ReserveExactError>
Source§impl<const N: usize> IoBufMut for [u8; N]
impl<const N: usize> IoBufMut for [u8; N]
fn as_uninit(&mut self) -> &mut [MaybeUninit<u8>]
Implementors§
impl IoBufMut for BorrowedBuf<'static, u8>
read_buf only.impl IoBufMut for BufferRef
impl IoBufMut for BytesMut
bytes only.impl IoBufMut for MmapMut
memmap2 only.impl<A> IoBufMut for Vec<u8, A>where
A: Allocator + 'static,
impl<B, A> IoBufMut for Box<B, A>
impl<T> IoBufMut for Slice<T>where
T: IoBufMut,
impl<T> IoBufMut for Uninit<T>where
T: IoBufMut,
impl<T> IoBufMut for VectoredBufIter<T>where
T: IoVectoredBufMut,
impl<const N: usize> IoBufMut for AncillaryBuf<N>
impl<const N: usize> IoBufMut for ArrayVec<u8, N>
arrayvec only.impl<const N: usize> IoBufMut for SmallVec<[u8; N]>
smallvec only.