BufferReaderChild

Struct BufferReaderChild 

Source
pub struct BufferReaderChild<'a, 'b> { /* private fields */ }
Expand description

It acts like a copy of a parent BufferReader.

You can create this from BufferReader::child. The child offset will be set to 0, but its underlying buffer will start from the current parent’s offset.

Having a copy it allows reading the buffer preserving the parent’s original offset.

If you want to commit the number of bytes read to the parent, use BufferReaderChild::commit. Instead, dropping this without committing, it will not alter the parent.

Implementations§

Source§

impl<'a, 'b> BufferReaderChild<'a, 'b>

Source

pub fn commit(self)

Advances the parent BufferReader offset of the amount read with this child.

Methods from Deref<Target = BufferReader<'a>>§

Source

pub fn capacity(&self) -> usize

Returns the remaining capacity in the buffer.

Source

pub fn offset(&self) -> usize

Returns the current offset of the buffer.

Source

pub fn skip(&mut self, len: usize) -> Result<(), EndOfBuffer>

Advances the offset.

In case of Err the offset is not advanced.

Source

pub fn buffer(&self) -> &'a [u8]

Returns a reference to the internal buffer.

Note: this is the entire buffer (despite offset).

Source

pub fn buffer_remaining(&mut self) -> &'a [u8]

Returns the inner buffer starting from the current offset.

Source

pub fn child(&mut self) -> BufferReaderChild<'a, '_>

Creates a BufferReaderChild with this parent.

Trait Implementations§

Source§

impl<'a> Deref for BufferReaderChild<'a, '_>

Source§

type Target = BufferReader<'a>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for BufferReaderChild<'_, '_>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<'a, 'b> Freeze for BufferReaderChild<'a, 'b>

§

impl<'a, 'b> RefUnwindSafe for BufferReaderChild<'a, 'b>

§

impl<'a, 'b> Send for BufferReaderChild<'a, 'b>

§

impl<'a, 'b> Sync for BufferReaderChild<'a, 'b>

§

impl<'a, 'b> Unpin for BufferReaderChild<'a, 'b>

§

impl<'a, 'b> !UnwindSafe for BufferReaderChild<'a, 'b>

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.