Skip to main content

SliceSink

Struct SliceSink 

Source
pub struct SliceSink<'a> { /* private fields */ }
Expand description

SliceSink writes into a preallocated &mut [u8].

§Handling of Capacity

Extend methods will panic if there’s insufficient capacity left in the Sink.

§Invariants

  • Bytes [..pos()] are always initialized.

Implementations§

Source§

impl<'a> SliceSink<'a>

Source

pub fn new(output: &'a mut [u8], pos: usize) -> Self

Creates a Sink backed by the given byte slice. pos defines the initial output position in the Sink.

§Panics

Panics if pos is out of bounds.

Trait Implementations§

Source§

impl Sink for SliceSink<'_>

Source§

fn push(&mut self, byte: u8)

Pushes a byte to the end of the Sink.
Source§

fn pos(&self) -> usize

Current write position.
Source§

fn capacity(&self) -> usize

Total capacity of the underlying buffer.
Source§

fn extend_from_slice(&mut self, data: &[u8])

Extends the Sink with data.
Source§

fn extend_from_slice_wild(&mut self, data: &[u8], copy_len: usize)

Extends the Sink with data, but only advances pos by copy_len. Allows overcopying into the trailing slack for wildcopy.
Source§

fn extend_from_within_overlapping(&mut self, start: usize, num_bytes: usize)

Copies num_bytes from start within the output buffer, handling overlapping (periodic) patterns byte by byte.
Source§

fn output_mut_with_pos(&mut self) -> (&mut [u8], &mut usize)

Returns the underlying buffer and a mutable reference to the position.

Auto Trait Implementations§

§

impl<'a> !UnwindSafe for SliceSink<'a>

§

impl<'a> Freeze for SliceSink<'a>

§

impl<'a> RefUnwindSafe for SliceSink<'a>

§

impl<'a> Send for SliceSink<'a>

§

impl<'a> Sync for SliceSink<'a>

§

impl<'a> Unpin for SliceSink<'a>

§

impl<'a> UnsafeUnpin for SliceSink<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.