Struct PatternReader

Source
pub struct PatternReader<Ord: ByteOrder> { /* private fields */ }
Expand description

Read a number of elements from a stream,

usage of PatternReader is to build a pattern with the provided methods and then call call the read method with the stream to read from, the read method will return a vector of the read elements consuming the pattern, and leaving the stream at the end of the last read element.

Implementations§

Source§

impl PatternReader<BigEndian>

Source

pub fn new_be() -> Self

Source§

impl PatternReader<LittleEndian>

Source

pub fn new_le() -> Self

Source§

impl<Ord: ByteOrder> PatternReader<Ord>

Source

pub fn new() -> Self

Source

pub fn add_u8(&mut self) -> &mut Self

Source

pub fn add_u16(&mut self) -> &mut Self

Source

pub fn add_u32(&mut self) -> &mut Self

Source

pub fn add_u64(&mut self) -> &mut Self

Source

pub fn add_i8(&mut self) -> &mut Self

Source

pub fn add_i16(&mut self) -> &mut Self

Source

pub fn add_i32(&mut self) -> &mut Self

Source

pub fn add_i64(&mut self) -> &mut Self

Source

pub fn add_usize(&mut self) -> &mut Self

Source

pub fn add_padding(&mut self, len: usize) -> &mut Self

Source

pub fn add_bool(&mut self) -> &mut Self

Source

pub fn add_expr( &mut self, par_width: u8, expr: impl Fn(AnyInt) -> bool + 'static, ) -> &mut Self

Source

pub fn pattern_required_bytes(&self) -> u64

How many input bytes are required at least to statisfy this pattern.

§Returns

The number of bytes required to read this pattern.

Source

pub fn read_pattern<S: Read>(&self, stream: S) -> StreamResult<Vec<AnyInt>>

Read the stream according to the given format and return the result.

§Returns

a Vec<AnyInt> containing the read values.

Trait Implementations§

Source§

impl<Ord: Debug + ByteOrder> Debug for PatternReader<Ord>

Source§

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

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

impl<Ord: ByteOrder> Default for PatternReader<Ord>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<Ord> Freeze for PatternReader<Ord>

§

impl<Ord> !RefUnwindSafe for PatternReader<Ord>

§

impl<Ord> !Send for PatternReader<Ord>

§

impl<Ord> !Sync for PatternReader<Ord>

§

impl<Ord> Unpin for PatternReader<Ord>
where Ord: Unpin,

§

impl<Ord> !UnwindSafe for PatternReader<Ord>

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