Skip to main content

ReadBufCursor

Struct ReadBufCursor 

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

Cursor over the unfilled portion of a read buffer.

This provides methods to advance and modify the unfilled portion of the buffer.

Implementations§

Source§

impl ReadBufCursor<'_>

Source

pub unsafe fn as_mut(&mut self) -> &mut Vec<u8>

Returns a mutable reference to the underlying buffer.

§Safety

The caller must ensure that the buffer is properly initialized.

Source

pub fn filled(&self) -> &[u8]

Returns the filled portion of the buffer.

Source

pub unsafe fn advance(&mut self, n: usize)

Advances the cursor by n bytes.

§Safety

The caller must ensure that n bytes have been initialized in the buffer.

§Panics

Panics if advancing by n would cause an overflow.

Source

pub fn remaining(&self) -> usize

Returns the remaining capacity in the buffer.

Source

pub fn put_slice(&mut self, buf: &[u8])

Copies bytes from the provided buffer into this cursor.

§Panics

Panics if the buffer doesn’t have enough remaining capacity.

Trait Implementations§

Source§

impl<'a> Debug for ReadBufCursor<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

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

§

impl<'a> Freeze for ReadBufCursor<'a>

§

impl<'a> RefUnwindSafe for ReadBufCursor<'a>

§

impl<'a> Send for ReadBufCursor<'a>

§

impl<'a> Sync for ReadBufCursor<'a>

§

impl<'a> Unpin for ReadBufCursor<'a>

§

impl<'a> UnsafeUnpin for ReadBufCursor<'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.