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.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
Auto Trait Implementations
impl<'a, C> !UnwindSafe for OutBuffer<'a, C>
impl<'a, C> Freeze for OutBuffer<'a, C>
where
&'a mut C: Freeze,
C: ?Sized,
impl<'a, C> RefUnwindSafe for OutBuffer<'a, C>
where
&'a mut C: RefUnwindSafe,
C: ?Sized,
impl<'a, C> Send for OutBuffer<'a, C>
where
&'a mut C: Send,
C: ?Sized,
impl<'a, C> Sync for OutBuffer<'a, C>
where
&'a mut C: Sync,
C: ?Sized,
impl<'a, C> Unpin for OutBuffer<'a, C>
where
&'a mut C: Unpin,
C: ?Sized,
impl<'a, C> UnsafeUnpin for OutBuffer<'a, C>
where
&'a mut C: UnsafeUnpin,
C: ?Sized,
Blanket Implementations
impl<T> Any for OutBuffer<'a, C>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for OutBuffer<'a, C>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for OutBuffer<'a, C>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for OutBuffer<'a, C>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into<U> for OutBuffer<'a, C>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for OutBuffer<'a, C>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for OutBuffer<'a, C>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>