pub struct OutBuffer<'a, C>{ /* private fields */ }
Expand description
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§
source§impl<'a, C> OutBuffer<'a, C>
impl<'a, C> OutBuffer<'a, C>
sourcepub fn around(dst: &'a mut C) -> OutBuffer<'a, C>
pub fn around(dst: &'a mut C) -> OutBuffer<'a, C>
Returns a new OutBuffer
around the given slice.
Starts with pos = 0
.
sourcepub fn around_pos(dst: &'a mut C, pos: usize) -> OutBuffer<'a, C>
pub fn around_pos(dst: &'a mut C, pos: usize) -> OutBuffer<'a, C>
Returns a new OutBuffer
around the given slice, starting at the given position.
§Panics
If pos > dst.capacity()
.
sourcepub fn pos(&self) -> usize
pub fn pos(&self) -> usize
Returns the current cursor position.
Guaranteed to be <= self.capacity()
sourcepub fn as_slice<'b>(&'b self) -> &'a [u8] ⓘwhere
'b: 'a,
pub fn as_slice<'b>(&'b self) -> &'a [u8] ⓘwhere
'b: 'a,
Returns the part of this buffer that was written to.
sourcepub fn as_mut_ptr(&mut self) -> *mut u8
pub fn as_mut_ptr(&mut self) -> *mut u8
Returns a pointer to the start of this buffer.
Trait Implementations§
Auto Trait Implementations§
impl<'a, C> Freeze for OutBuffer<'a, C>where
C: ?Sized,
impl<'a, C> RefUnwindSafe for OutBuffer<'a, C>where
C: RefUnwindSafe + ?Sized,
impl<'a, C> Send for OutBuffer<'a, C>
impl<'a, C> Sync for OutBuffer<'a, C>
impl<'a, C> Unpin for OutBuffer<'a, C>where
C: ?Sized,
impl<'a, C> !UnwindSafe for OutBuffer<'a, C>
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