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>
impl<'a, const E: bool> VectoredReader<'a, E>
Sourcepub fn new(bytes: &'a [&'a [u8]]) -> Self
pub fn new(bytes: &'a [&'a [u8]]) -> Self
Create a VectoredReader
that can read data types sequentially from the vectored
slices bytes
.
Sourcepub fn advance(&mut self, amount: usize) -> Result<(), WireError>
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.
Sourcepub fn advance_up_to(&mut self, index: usize)
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.
Sourcepub fn finalize(&self) -> Result<(), WireError>
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().
Sourcepub fn finalize_after<T>(
action: Result<T, WireError>,
reader: &Self,
) -> Result<T, WireError>
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().
Sourcepub fn peek<T>(&self) -> Result<T, WireError>where
T: VectoredRead,
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.
Sourcepub fn peek_comp<T>(&mut self) -> Result<T, WireError>where
T: VectoredReadComp<'a>,
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.
Sourcepub fn peek_part<T, const L: usize>(&mut self) -> Result<T, WireError>where
T: VectoredReadPart,
pub fn peek_part<T, const L: usize>(&mut self) -> Result<T, WireError>where
T: VectoredReadPart,
Read the given data type T
from L
bytes on the vectored wire without
advancing the index of the reader.
Sourcepub fn peek_ref<T>(&self, size: usize) -> Result<&'a T, WireError>where
T: VectoredReadRef + ?Sized,
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.
Sourcepub fn read<T>(&mut self) -> Result<T, WireError>where
T: VectoredRead,
pub fn read<T>(&mut self) -> Result<T, WireError>where
T: VectoredRead,
Read the given data type T
from the vectored wire.
Sourcepub fn read_comp<T>(&mut self) -> Result<T, WireError>where
T: VectoredReadComp<'a>,
pub fn read_comp<T>(&mut self) -> Result<T, WireError>where
T: VectoredReadComp<'a>,
Read the given data type T
from the vectored wire.
Sourcepub fn red_part<T, const L: usize>(&mut self) -> Result<T, WireError>where
T: VectoredReadPart,
pub fn red_part<T, const L: usize>(&mut self) -> Result<T, WireError>where
T: VectoredReadPart,
Read the given data type T
from size
bytes on the
vectored wire.
Sourcepub fn read_ref<T>(&mut self, size: usize) -> Result<&'a T, WireError>where
T: VectoredReadRef + ?Sized,
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.
Sourcepub fn read_remaining<T>(&mut self) -> Result<&'a T, WireError>where
T: VectoredReadRef + ?Sized,
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>
impl<'a, const E: bool> Clone for VectoredReader<'a, E>
Source§fn clone(&self) -> VectoredReader<'a, E>
fn clone(&self) -> VectoredReader<'a, E>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more