Struct OutBuffer
pub struct OutBuffer<'a, C: WriteBuf + ?Sized> { /* private fields */ }
Wrapper around an output buffer.
C is usually either [u8] or Vec<u8>.
Bytes will be written starting at dst[pos].
pos will be updated after writing.
Invariant
pos <= dst.capacity()
Implementations
impl<'a, C: WriteBuf + ?Sized> OutBuffer<'a, C>
fn around(dst: &'a mut C) -> SelfReturns a new
OutBufferaround the given slice.Starts with
pos = 0.fn around_pos(dst: &'a mut C, pos: usize) -> SelfReturns a new
OutBufferaround the given slice, starting at the given position.If
posis past the initialized part ofdst(for example aVecwhoselen()is smaller thanpos), the gap is zero-filled, as aCursorwould do.Panics
If
pos > dst.capacity().fn pos(&self) -> usizeReturns the current cursor position.
Guaranteed to be <= self.capacity()
fn capacity(&self) -> usizeReturns the capacity of the underlying buffer.
unsafe fn set_pos(&mut self, pos: usize)Sets the new cursor position.
Panics
If
pos > self.dst.capacity().Safety
Data up to
posmust have actually been written to.fn as_slice<'b>(&'b self) -> &'a [u8] where 'b: 'a,Returns the part of this buffer that was written to.
fn as_mut_ptr(&mut self) -> *mut u8Returns a pointer to the start of this buffer.
Trait Implementations
impl<'a, C: Debug + WriteBuf + ?Sized> Debug for OutBuffer<'a, C>
fn fmt(&self, f: &mut Formatter<'_>) -> Result