Skip to main content

Reader

Struct Reader 

Source
pub struct Reader<'a> { /* private fields */ }
Expand description

A cursor over big-endian data.

Implementations§

Source§

impl<'a> Reader<'a>

Source

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

A reader at the start of data.

Source

pub fn pos(&self) -> usize

The current position.

Source

pub fn seek(&mut self, pos: usize)

Moves to an absolute position.

Source

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

The whole underlying data.

Source

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

The data from the current position on.

Source

pub fn remaining(&self) -> usize

The number of bytes left.

Source

pub fn bytes(&mut self, n: usize) -> Result<&'a [u8]>

Reads n bytes.

Source

pub fn array<const N: usize>(&mut self) -> Result<[u8; N]>

Reads a fixed-size array.

Source

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

Skips n bytes.

Source

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

Reads a big-endian u8.

Source

pub fn i8(&mut self) -> Result<i8>

Reads a big-endian i8.

Source

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

Reads a big-endian u16.

Source

pub fn i16(&mut self) -> Result<i16>

Reads a big-endian i16.

Source

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

Reads a big-endian u32.

Source

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

Reads a big-endian i32.

Source

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

Reads a big-endian u64.

Source

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

Reads a big-endian i64.

Source

pub fn u24(&mut self) -> Result<u32>

Reads a 24-bit unsigned integer.

Source

pub fn tag(&mut self) -> Result<Tag>

Reads a tag.

Source

pub fn u16_array(&mut self, count: usize) -> Result<Vec<u16>>

Reads count big-endian u16s.

Source

pub fn i16_array(&mut self, count: usize) -> Result<Vec<i16>>

Reads count big-endian i16s.

Source

pub fn u32_array(&mut self, count: usize) -> Result<Vec<u32>>

Reads count big-endian u32s.

Trait Implementations§

Source§

impl<'a> Clone for Reader<'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> Debug for Reader<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Forget for Reader<'a>

§

impl<'a> Freeze for Reader<'a>
where &'a [u8]: Freeze,

§

impl<'a> Move for Reader<'a>

§

impl<'a> RefUnwindSafe for Reader<'a>

§

impl<'a> Send for Reader<'a>
where &'a [u8]: Send,

§

impl<'a> Sync for Reader<'a>

§

impl<'a> Unpin for Reader<'a>
where &'a [u8]: Unpin,

§

impl<'a> UnsafeUnpin for Reader<'a>
where &'a [u8]: UnsafeUnpin,

§

impl<'a> UnwindSafe for Reader<'a>
where &'a [u8]: 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> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

self as &dyn Any.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

self as &mut dyn Any.
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.