Skip to main content

Cursor

Struct Cursor 

Source
pub struct Cursor<'a>(/* private fields */);
Expand description

Cursor over a borrowed byte slice, reading big-endian values from the front.

Implementations§

Source§

impl<'a> Cursor<'a>

Source

pub fn new(bytes: &'a [u8]) -> Self

Creates a cursor positioned at the start of bytes.

Source

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

Returns the not yet consumed bytes.

Source

pub fn len(&self) -> usize

Returns the number of not yet consumed bytes.

Source

pub fn is_empty(&self) -> bool

Returns true if everything has been consumed.

Trait Implementations§

Source§

impl<'a> Clone for Cursor<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for Cursor<'a>

Source§

impl<'a> Debug for Cursor<'a>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a> From<&'a [u8]> for Cursor<'a>

Source§

fn from(value: &'a [u8]) -> Self

Converts to this type from the input type.
Source§

impl<'a> ReadBytes<'a> for Cursor<'a>

Source§

fn read_bytes(&mut self, len: usize) -> Result<&'a [u8]>

Consumes exactly len bytes, or fails with Error::UnexpectedEof.
Source§

fn read_rest(&mut self) -> &'a [u8] ⓘ

Consumes and returns everything that is left.
Source§

fn read_u8(&mut self) -> Result<u8>

Reads a big-endian value, advancing past it.
Source§

fn read_u16(&mut self) -> Result<u16>

Reads a big-endian value, advancing past it.
Source§

fn read_u32(&mut self) -> Result<u32>

Reads a big-endian value, advancing past it.
Source§

fn read_u64(&mut self) -> Result<u64>

Reads a big-endian value, advancing past it.
Source§

fn read_i32(&mut self) -> Result<i32>

Reads a big-endian value, advancing past it.
Source§

fn read_i64(&mut self) -> Result<i64>

Reads a big-endian value, advancing past it.
Source§

fn read_f32(&mut self) -> Result<f32>

Reads an IEEE 754 single-precision float.
Source§

fn read_f64(&mut self) -> Result<f64>

Reads an IEEE 754 double-precision float.
Source§

fn repeat_by_u16<T>( &mut self, fun: impl FnMut(&mut Self) -> Result<T>, ) -> Result<Vec<T>>
where Self: Sized,

Reads a u16 count, then applies fun that many times.
Source§

fn repeat_by_u8<T>( &mut self, fun: impl FnMut(&mut Self) -> Result<T>, ) -> Result<Vec<T>>
where Self: Sized,

Reads a u8 count, then applies fun that many times.
Source§

fn read_indices(&mut self) -> Result<Vec<CpIndex>>
where Self: Sized,

Reads a u16-prefixed list of constant pool indices.
Source§

fn read_optional_index(&mut self) -> Result<Option<CpIndex>>

Reads a constant pool index where 0 means “absent”.

Auto Trait Implementations§

§

impl<'a> Freeze for Cursor<'a>

§

impl<'a> RefUnwindSafe for Cursor<'a>

§

impl<'a> Send for Cursor<'a>

§

impl<'a> Sync for Cursor<'a>

§

impl<'a> Unpin for Cursor<'a>

§

impl<'a> UnsafeUnpin for Cursor<'a>

§

impl<'a> UnwindSafe for Cursor<'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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.