pub struct Buf<'a> { /* private fields */ }
Expand description
An accessor for writing to a partially-initialized byte buffer.
Implementations§
source§impl<'a> Buf<'a>
impl<'a> Buf<'a>
sourcepub fn push(&mut self, b: u8)
pub fn push(&mut self, b: u8)
Extends the initialized portion of the buffer with b
. Panics if it
doesn’t fit.
sourcepub fn append(&mut self, buf: &[u8])
pub fn append(&mut self, buf: &[u8])
Extends the initialized portion of the buffer with buf
. Panics if the
data does not fit.
sourcepub fn fill(&mut self, val: u8, len: usize)
pub fn fill(&mut self, val: u8, len: usize)
Extends the initialized portion of the buffer with len
bytes equal to
val
. Panics if the data does not fit.
sourcepub fn write_split<R>(
&mut self,
split_at: usize,
f: impl FnOnce(Buf<'_>, Buf<'_>) -> R,
) -> R
pub fn write_split<R>( &mut self, split_at: usize, f: impl FnOnce(Buf<'_>, Buf<'_>) -> R, ) -> R
Splits this buffer into two at split_at
and calls f
to fill out each
part.
If the left buffer is not filled in full but the right buffer is partially initialized, then the remainder of the left buffer will be zero-initialized.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Buf<'a>
impl<'a> RefUnwindSafe for Buf<'a>
impl<'a> Send for Buf<'a>
impl<'a> Sync for Buf<'a>
impl<'a> Unpin for Buf<'a>
impl<'a> !UnwindSafe for Buf<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more