pub struct ReadBuf<'a> { /* private fields */ }Expand description
A buffer being filled by reads: its first filled bytes hold data, its
first initialized bytes are initialized (filled <= initialized), and
the rest may be uninitialized memory that a read may write into.
Implementations§
Source§impl<'a> ReadBuf<'a>
impl<'a> ReadBuf<'a>
Sourcepub fn new(buf: &'a mut [u8]) -> Self
pub fn new(buf: &'a mut [u8]) -> Self
A buffer over buf, all of it initialized, none of it filled.
Sourcepub fn uninit(buf: &'a mut [MaybeUninit<u8>]) -> Self
pub fn uninit(buf: &'a mut [MaybeUninit<u8>]) -> Self
A buffer over buf, none of it initialized or filled.
Sourcepub fn filled_mut(&mut self) -> &mut [u8] ⓘ
pub fn filled_mut(&mut self) -> &mut [u8] ⓘ
The bytes filled so far, to change.
Sourcepub fn initialized(&self) -> &[u8] ⓘ
pub fn initialized(&self) -> &[u8] ⓘ
The bytes known to be initialized, filled or not.
Sourcepub fn initialized_mut(&mut self) -> &mut [u8] ⓘ
pub fn initialized_mut(&mut self) -> &mut [u8] ⓘ
The bytes known to be initialized, to change.
Sourcepub fn take(&mut self, n: usize) -> ReadBuf<'_>
pub fn take(&mut self, n: usize) -> ReadBuf<'_>
A buffer over at most n bytes of the unfilled part, sharing what is
known to be initialized there.
Sourcepub fn initialize_unfilled(&mut self) -> &mut [u8] ⓘ
pub fn initialize_unfilled(&mut self) -> &mut [u8] ⓘ
Initializes the whole unfilled part (zeroing what was not initialized) and answers it, for a read to write into.
Sourcepub fn initialize_unfilled_to(&mut self, n: usize) -> &mut [u8] ⓘ
pub fn initialize_unfilled_to(&mut self, n: usize) -> &mut [u8] ⓘ
Sourcepub fn set_filled(&mut self, n: usize)
pub fn set_filled(&mut self, n: usize)
Sourcepub unsafe fn assume_init(&mut self, n: usize)
pub unsafe fn assume_init(&mut self, n: usize)
Counts the first n bytes of the unfilled part as initialized.
§Safety
The caller has initialized those bytes.
Sourcepub unsafe fn unfilled_mut(&mut self) -> &mut [MaybeUninit<u8>]
pub unsafe fn unfilled_mut(&mut self) -> &mut [MaybeUninit<u8>]
The unfilled part, as memory that may be uninitialized.
§Safety
The caller must not write uninitialized bytes into it: the part known to be initialized must stay initialized.