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<Ord: ByteOrder> PatternReader<Ord>
impl<Ord: ByteOrder> PatternReader<Ord>
pub fn new() -> Self
pub fn add_u8(&mut self) -> &mut Self
pub fn add_u16(&mut self) -> &mut Self
pub fn add_u32(&mut self) -> &mut Self
pub fn add_u64(&mut self) -> &mut Self
pub fn add_i8(&mut self) -> &mut Self
pub fn add_i16(&mut self) -> &mut Self
pub fn add_i32(&mut self) -> &mut Self
pub fn add_i64(&mut self) -> &mut Self
pub fn add_usize(&mut self) -> &mut Self
pub fn add_padding(&mut self, len: usize) -> &mut Self
pub fn add_bool(&mut self) -> &mut Self
pub fn add_expr( &mut self, par_width: u8, expr: impl Fn(AnyInt) -> bool + 'static, ) -> &mut Self
Sourcepub fn pattern_required_bytes(&self) -> u64
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.
Sourcepub fn read_pattern<S: Read>(&self, stream: S) -> StreamResult<Vec<AnyInt>>
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more