Struct ReadBuf
struct ReadBuf<'a> { ... }
A wrapper around a byte buffer that is incrementally filled and initialized.
This type is a sort of "double cursor". It tracks three regions in the buffer: a region at the beginning of the buffer that has been logically filled with data, a region that has been initialized at some point but not yet logically filled, and a region at the end that may be uninitialized. The filled region is guaranteed to be a subset of the initialized region.
In summary, the contents of the buffer can be visualized as:
[ capacity ]
[ filled | unfilled ]
[ initialized | uninitialized ]
It is undefined behavior to de-initialize any bytes from the uninitialized region, since it is merely unknown whether this region is uninitialized or not, and if part of it turns out to be initialized, it must stay initialized.
Implementations
impl<'data> ReadBuf<'data>
fn new(raw: &'data mut [u8]) -> SelfCreate a new
ReadBufwith a slice of initialized bytes.fn uninit(raw: &'data mut [MaybeUninit<u8>]) -> SelfCreate a new
ReadBufwith a slice of uninitialized bytes.fn filled(self: &Self) -> &[u8]Get a slice of the buffer that has been filled in with bytes.
fn unfilled<'cursor>(self: &'cursor mut Self) -> ReadBufCursor<'cursor>Get a cursor to the unfilled portion of the buffer.
impl Debug for ReadBuf<'_>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl<'a> Freeze for ReadBuf<'a>
impl<'a> RefUnwindSafe for ReadBuf<'a>
impl<'a> Send for ReadBuf<'a>
impl<'a> Sync for ReadBuf<'a>
impl<'a> Unpin for ReadBuf<'a>
impl<'a> UnsafeUnpin for ReadBuf<'a>
impl<'a> UnwindSafe for ReadBuf<'a>
impl<T> Any for ReadBuf<'a>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for ReadBuf<'a>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for ReadBuf<'a>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> From for ReadBuf<'a>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Instrument for ReadBuf<'a>
impl<T> WithSubscriber for ReadBuf<'a>
impl<T, U> Into for ReadBuf<'a>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for ReadBuf<'a>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for ReadBuf<'a>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>