Skip to main content

Reader

Struct Reader 

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

A cursor over a byte slice that reads little-endian values.

Implementations§

Source§

impl<'a> Reader<'a>

Source

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

A reader at the start of buf.

Source

pub fn remaining(&self) -> usize

Bytes not yet read.

Source

pub fn is_empty(&self) -> bool

True when everything has been read.

Source

pub fn position(&self) -> usize

Current offset from the start.

Source

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

The next n bytes.

Source

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

Everything not yet read.

Source

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

A fixed-size array.

Source

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

One byte.

Source

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

One signed byte.

Source

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

A little-endian u16.

Source

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

A little-endian u32.

Source

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

A little-endian u64.

Source

pub fn uint_n(&mut self, width: usize) -> Result<u64, Truncated>

A little-endian unsigned integer of width bytes (1 to 8).

Source

pub fn bool(&mut self) -> Result<bool, Truncated>

A boolean byte (non-zero is true).

Source

pub fn ieee(&mut self) -> Result<Ieee, Truncated>

An IEEE address in wire order.

Source

pub fn ext_pan_id(&mut self) -> Result<ExtPanId, Truncated>

An extended PAN id in wire order.

Source

pub fn key(&mut self) -> Result<Key, Truncated>

A 16-byte key, in byte order.

Source

pub fn u8_prefixed(&mut self) -> Result<&'a [u8], Truncated>

A byte string prefixed by a one-byte length.

Source

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

count little-endian u16 values.

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> Freeze for Reader<'a>

§

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

§

impl<'a> Send for Reader<'a>

§

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

§

impl<'a> Unpin for Reader<'a>

§

impl<'a> UnsafeUnpin for Reader<'a>

§

impl<'a> UnwindSafe for Reader<'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.