Trait IoBufMut
pub unsafe trait IoBufMut: IoBuf + SetLen {
// Required method
fn as_uninit(&mut self) -> &mut [MaybeUninit<u8>];
// Provided methods
fn buf_capacity(&mut self) -> usize { ... }
fn buf_mut_ptr(&mut self) -> *mut u8 { ... }
fn spare_mut(&mut self) -> &mut [MaybeUninit<u8>] { ... }
fn as_mut_slice(&mut self) -> &mut [u8] ⓘ { ... }
fn uninit(self) -> Uninit<Self>
where Self: Sized { ... }
}Expand description
An IoBuf that can also be written into (i.e. used as a read destination).
§Safety
as_uninit must expose the buffer’s full backing storage
— the initialized prefix [0, buf_len) followed by writable spare
[buf_len, capacity) — and the spare must be safe to write. Same address
stability contract as IoBuf.
Required Methods§
fn as_uninit(&mut self) -> &mut [MaybeUninit<u8>]
fn as_uninit(&mut self) -> &mut [MaybeUninit<u8>]
The full backing storage as possibly-uninitialized bytes: the initialized
prefix [0, buf_len) plus the writable spare [buf_len, capacity).
The core accessor: capacity, the raw pointer, and the read-target spare
all derive from it, and a reader fills spare_mut
(a safe &mut [MaybeUninit<u8>]) instead of doing raw pointer arithmetic.
Provided Methods§
fn buf_capacity(&mut self) -> usize
fn buf_capacity(&mut self) -> usize
Total capacity (as_uninit().len()).
fn buf_mut_ptr(&mut self) -> *mut u8
fn buf_mut_ptr(&mut self) -> *mut u8
fn spare_mut(&mut self) -> &mut [MaybeUninit<u8>]
fn spare_mut(&mut self) -> &mut [MaybeUninit<u8>]
The writable spare tail [buf_len, capacity) — the read destination.
fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
The initialized region [0, buf_len) as a mutable slice, for an
in-place transform (e.g. decrypting a TLS record inside the very buffer it
arrived in, no copy).
fn uninit(self) -> Uninit<Self>where
Self: Sized,
fn uninit(self) -> Uninit<Self>where
Self: Sized,
A read-target view of just the writable spare [buf_len, capacity).
Reading into it appends to self (the view’s offset 0 is self’s
buf_len), so it’s how you accumulate on top of the overwrite-from-0 read
primitive, e.g. read_exact loops read_owned(buf.uninit()). The owned
analogue of compio’s Uninit.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".