Struct VectoredReader

Source
pub struct VectoredReader<'a, const E: bool = true> { /* private fields */ }
Expand description

A wrapper around a slice of &[u8] slices that provides an easy interface for reading data types from the vectored slices.

Implementations§

Source§

impl<'a, const E: bool> VectoredReader<'a, E>

Source

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

Create a VectoredReader that can read data types sequentially from the vectored slices bytes.

Source

pub fn advance(&mut self, amount: usize) -> Result<(), WireError>

Advance the reader’s index forward by the given amount of bytes, returning an error if there are insufficient bytes on the wire to do so.

Source

pub fn advance_up_to(&mut self, index: usize)

Advance the reader’s index forward by the given number of bytes, or to the end of the wire if the amount exceeds the number of remaining bytes.

Source

pub fn finalize(&self) -> Result<(), WireError>

Check if the reader has no more bytes left on the vectored wire that can be read. If any bytes remain, return WireError::ExtraBytes; otherwise, return Ok().

Source

pub fn finalize_after<T>( action: Result<T, WireError>, reader: &Self, ) -> Result<T, WireError>

Check if the reader has no more bytes left on the vectored wire that can be read after the given action. If any bytes remain, return WireError::ExtraBytes; otherwise, return Ok().

Source

pub fn is_empty(&self) -> bool

Check whether the reader has any remaining bytes to be read.

Source

pub fn peek<T>(&self) -> Result<T, WireError>
where T: VectoredRead,

Read the given data type T from the vectored wire without advancing the index of the reader.

Source

pub fn peek_comp<T>(&mut self) -> Result<T, WireError>
where T: VectoredReadComp<'a>,

Read the given data type T from the vectored wire without advancing the index of the reader.

Source

pub fn peek_part<T, const L: usize>(&mut self) -> Result<T, WireError>

Read the given data type T from L bytes on the vectored wire without advancing the index of the reader.

Source

pub fn peek_ref<T>(&self, size: usize) -> Result<&'a T, WireError>
where T: VectoredReadRef + ?Sized,

Read the given data type T from size bytes on the vectored wire without advancing the index of the reader.

Source

pub fn read<T>(&mut self) -> Result<T, WireError>
where T: VectoredRead,

Read the given data type T from the vectored wire.

Source

pub fn read_comp<T>(&mut self) -> Result<T, WireError>
where T: VectoredReadComp<'a>,

Read the given data type T from the vectored wire.

Source

pub fn red_part<T, const L: usize>(&mut self) -> Result<T, WireError>

Read the given data type T from size bytes on the vectored wire.

Source

pub fn read_ref<T>(&mut self, size: usize) -> Result<&'a T, WireError>
where T: VectoredReadRef + ?Sized,

Read the given data type T from the vectored wire.

Source

pub fn read_remaining<T>(&mut self) -> Result<&'a T, WireError>
where T: VectoredReadRef + ?Sized,

Read the given data type T from the remaining data on the vectored wire. Note that this operation may succeed even if there are no bytes remaining on the vectored wire for the given reader.

Trait Implementations§

Source§

impl<'a, const E: bool> Clone for VectoredReader<'a, E>

Source§

fn clone(&self) -> VectoredReader<'a, E>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl From<VectoredReader<'_>> for WireIndex

Source§

fn from(reader: VectoredReader<'_>) -> Self

Converts to this type from the input type.
Source§

impl<'a, const E: bool> Copy for VectoredReader<'a, E>

Auto Trait Implementations§

§

impl<'a, const E: bool> Freeze for VectoredReader<'a, E>

§

impl<'a, const E: bool> RefUnwindSafe for VectoredReader<'a, E>

§

impl<'a, const E: bool> Send for VectoredReader<'a, E>

§

impl<'a, const E: bool> Sync for VectoredReader<'a, E>

§

impl<'a, const E: bool> Unpin for VectoredReader<'a, E>

§

impl<'a, const E: bool> UnwindSafe for VectoredReader<'a, E>

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 = 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.