pub struct Cursor<I> {
    pub buf: I,
    pub pos: Cell<usize>,
}
Expand description

A cursor based [BufReader<'de>] implementation.

Fields§

§buf: I

The underlying input read from.

§pos: Cell<usize>

The position within the reader.

Implementations§

source§

impl<I> Cursor<I>

source

pub fn new(buf: I) -> Self

Returns a new cursor on the provided buf input.

The cursor starts at the beginning of buf.

Trait Implementations§

source§

impl<'de, I: AsRef<[u8]>> BufReader<'de> for &'de Cursor<I>

source§

fn get_slice(&mut self, size: usize) -> Result<&'de [u8], DecodeError>

Reads and returns a byte slice of .len() = size advancing the cursor.
source§

fn remaining(&self) -> usize

Returns the number of bytes left to read in the input.
source§

fn get_u8(&mut self) -> Result<u8, DecodeError>

Reads a u8 in little endian (LE) encoding from the input. Read more
source§

fn get_u16(&mut self) -> Result<u16, DecodeError>

Reads a u16 in little endian (LE) encoding from the input. Read more
source§

fn get_u32(&mut self) -> Result<u32, DecodeError>

Reads a u32 in little endian (LE) encoding from the input. Read more
source§

fn get_u64(&mut self) -> Result<u64, DecodeError>

Reads a u64 in little endian (LE) encoding from the input. Read more
source§

fn get_u128(&mut self) -> Result<u128, DecodeError>

Reads a u128 in little endian (LE) encoding from the input. Read more
source§

fn get_i8(&mut self) -> Result<i8, DecodeError>

Reads an i8 in little endian (LE) encoding from the input. Read more
source§

fn get_i16(&mut self) -> Result<i16, DecodeError>

Reads an i16 in little endian (LE) encoding from the input. Read more
source§

fn get_i32(&mut self) -> Result<i32, DecodeError>

Reads an i32 in little endian (LE) encoding from the input. Read more
source§

fn get_i64(&mut self) -> Result<i64, DecodeError>

Reads an i64 in little endian (LE) encoding from the input. Read more
source§

fn get_i128(&mut self) -> Result<i128, DecodeError>

Reads an i128 in little endian (LE) encoding from the input. Read more
source§

fn get_array<const C: usize>(&mut self) -> Result<[u8; C], DecodeError>

Reads an array of type [u8; C] from the input.

Auto Trait Implementations§

§

impl<I> !RefUnwindSafe for Cursor<I>

§

impl<I> Send for Cursor<I>
where I: Send,

§

impl<I> !Sync for Cursor<I>

§

impl<I> Unpin for Cursor<I>
where I: Unpin,

§

impl<I> UnwindSafe for Cursor<I>
where I: UnwindSafe,

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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more