Trait IoBufMut

Source
pub unsafe trait IoBufMut: IoBuf {
    // Required methods
    fn stable_mut_ptr(&mut self) -> *mut u8;
    unsafe fn set_init(&mut self, pos: usize);
}
Expand description

A mutableio-uring compatible buffer.

The IoBufMut trait is implemented by buffer types that can be passed to io-uring operations. Users will not need to use this trait directly.

§Safety

Buffers passed to io-uring operations must reference a stable memory region. While the runtime holds ownership to a buffer, the pointer returned by stable_mut_ptr must remain valid even if the IoBufMut value is moved.

Required Methods§

Source

fn stable_mut_ptr(&mut self) -> *mut u8

Returns a raw mutable pointer to the vector’s buffer.

This method is to be used by the tokio-uring runtime and it is not expected for users to call it directly.

The implementation must ensure that, while the tokio-uring runtime owns the value, the pointer returned by stable_mut_ptr does not change.

Source

unsafe fn set_init(&mut self, pos: usize)

Updates the number of initialized bytes.

The specified pos becomes the new value returned by IoBuf::bytes_init.

§Safety

The caller must ensure that all bytes starting at stable_mut_ptr() up to pos are initialized and owned by the buffer.

Implementations on Foreign Types§

Source§

impl IoBufMut for Vec<u8>

Source§

fn stable_mut_ptr(&mut self) -> *mut u8

Source§

unsafe fn set_init(&mut self, init_len: usize)

Source§

impl IoBufMut for BytesMut

Source§

fn stable_mut_ptr(&mut self) -> *mut u8

Source§

unsafe fn set_init(&mut self, pos: usize)

Source§

impl<T: IoBufMut> IoBufMut for Box<T>

Source§

fn stable_mut_ptr(&mut self) -> *mut u8

Source§

unsafe fn set_init(&mut self, pos: usize)

Implementors§

Source§

impl<T: AsBytes + Unpin + 'static> IoBufMut for ZeroCopyBuf<T>

Source§

impl<T: AsBytes + FromBytes + Unpin + 'static> IoBufMut for ZeroCopyBoxIoBuf<T>