pub unsafe trait IoBufMut: IoBuf + SetBufInit {
// Required method
fn as_buf_mut_ptr(&mut self) -> *mut u8;
// Provided methods
fn as_mut_slice(&mut self) -> &mut [MaybeUninit<u8>] { ... }
unsafe fn as_io_slice_mut(&mut self) -> IoSliceMut { ... }
}
Expand description
A mutable compio compatible buffer.
The IoBufMut
trait is implemented by buffer types that can be passed to
compio operations. Users will not need to use this trait directly.
§Safety
Buffers passed to compio operations must reference a stable memory
region. While the runtime holds ownership to a buffer, the pointer returned
by as_buf_mut_ptr
must remain valid even if the IoBufMut
value is moved.
Required Methods§
Sourcefn as_buf_mut_ptr(&mut self) -> *mut u8
fn as_buf_mut_ptr(&mut self) -> *mut u8
Returns a raw mutable pointer to the vector’s buffer.
This method is to be used by the compio
runtime and it is not
expected for users to call it directly.
Provided Methods§
Sourcefn as_mut_slice(&mut self) -> &mut [MaybeUninit<u8>]
fn as_mut_slice(&mut self) -> &mut [MaybeUninit<u8>]
Get the uninitialized part of the buffer.
Sourceunsafe fn as_io_slice_mut(&mut self) -> IoSliceMut
unsafe fn as_io_slice_mut(&mut self) -> IoSliceMut
Create an IoSliceMut
of the uninitialized part of the buffer.
§Safety
The return slice will not live longer than self. It is static to provide convenience from writing self-referenced structure.
Implementations on Foreign Types§
Source§impl IoBufMut for BorrowedBuf<'static>
Available on crate feature read_buf
only.
impl IoBufMut for BorrowedBuf<'static>
read_buf
only.fn as_buf_mut_ptr(&mut self) -> *mut u8
Source§impl IoBufMut for BytesMut
Available on crate feature bytes
only.
impl IoBufMut for BytesMut
bytes
only.fn as_buf_mut_ptr(&mut self) -> *mut u8
Source§impl<A: Allocator + 'static> IoBufMut for Vec<u8, A>
impl<A: Allocator + 'static> IoBufMut for Vec<u8, A>
fn as_buf_mut_ptr(&mut self) -> *mut u8
Source§impl<B: IoBufMut + ?Sized> IoBufMut for &'static mut B
impl<B: IoBufMut + ?Sized> IoBufMut for &'static mut B
fn as_buf_mut_ptr(&mut self) -> *mut u8
Source§impl<B: IoBufMut + ?Sized, A: Allocator + 'static> IoBufMut for Box<B, A>
impl<B: IoBufMut + ?Sized, A: Allocator + 'static> IoBufMut for Box<B, A>
fn as_buf_mut_ptr(&mut self) -> *mut u8
Source§impl<const N: usize> IoBufMut for ArrayVec<u8, N>
Available on crate feature arrayvec
only.
impl<const N: usize> IoBufMut for ArrayVec<u8, N>
arrayvec
only.fn as_buf_mut_ptr(&mut self) -> *mut u8
Source§impl<const N: usize> IoBufMut for SmallVec<[u8; N]>
Available on crate feature smallvec
only.
impl<const N: usize> IoBufMut for SmallVec<[u8; N]>
smallvec
only.