Cursor

Struct Cursor 

Source
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) -> Cursor<I>

Returns a new cursor on the provided buf input.

The cursor starts at the beginning of buf.

Trait Implementations§

Source§

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

Source§

fn get_chunk(&mut self, size: usize) -> Option<&'de [u8]>

Reads and returns a chunk of .len() = size advancing the cursor iff self.remaining() >= size.
Source§

fn get_array_chunk<const N: usize>(&mut self) -> Option<&'de [u8; N]>

Reads and returns a chunk of .len() = N as an array, advancing the cursor.
Source§

fn remaining(&self) -> usize

Returns the number of bytes left to read in the input.
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 get_array<const N: usize>(&mut self) -> Result<&'de [u8; N], DecodeError>

Reads an array of type [u8; N] from 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_u256(&mut self) -> Result<U256, DecodeError>

Reads a u256 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_i256(&mut self) -> Result<I256, DecodeError>

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

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

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<I> !Freeze for Cursor<I>

§

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, 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.