Struct ReadFromTail

Source
pub struct ReadFromTail<'a, R>(pub &'a mut R)
where
    R: TailReadBytes;
Expand description

Adapter which implements ReadBytes for reading from the end of the buffer.

let buf = vec![11, 22, 33, 44, 55, 0, 1];
let mut reader = DeBytesReader::new(&buf);
assert_eq!(<u16>::from_reader(ReadFromTail(&mut reader), params::AscendingOrder).unwrap(), 1);

Tuple Fields§

§0: &'a mut R

Trait Implementations§

Source§

impl<'a, R> ReadBytes for ReadFromTail<'a, R>
where R: TailReadBytes,

Source§

fn peek<F, RV>(&mut self, n: usize, f: F) -> Result<RV>
where F: FnOnce(&[u8]) -> Result<RV>,

Peek n bytes from head
Source§

fn advance(&mut self, n: usize)

Advance buffer head by n bytes. n should be smaller than remaining buffer size.
Source§

fn remaining_buffer(&mut self) -> &[u8]

Returns view into remaining buffer
Source§

fn read<F, R>(&mut self, n: usize, f: F) -> Result<R>
where F: FnOnce(&[u8]) -> Result<R>,

Get n bytes from the beginning of buffer, advance by n bytes
Source§

fn is_complete(&mut self) -> Result

Check if buffer is fully consumed (empty)

Auto Trait Implementations§

§

impl<'a, R> Freeze for ReadFromTail<'a, R>

§

impl<'a, R> RefUnwindSafe for ReadFromTail<'a, R>
where R: RefUnwindSafe,

§

impl<'a, R> Send for ReadFromTail<'a, R>
where R: Send,

§

impl<'a, R> Sync for ReadFromTail<'a, R>
where R: Sync,

§

impl<'a, R> Unpin for ReadFromTail<'a, R>

§

impl<'a, R> !UnwindSafe for ReadFromTail<'a, R>

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.