Skip to main content

StreamParser

Struct StreamParser 

Source
pub struct StreamParser { /* private fields */ }
Expand description

A streaming cursor over a byte buffer.

Implementations§

Source§

impl StreamParser

Source

pub fn new() -> Self

Source

pub fn feed(&mut self, data: &[u8])

Feed more data into the parser buffer.

Source

pub fn remaining(&self) -> usize

Remaining unread bytes.

Source

pub fn total_fed(&self) -> usize

Total bytes fed so far.

Source

pub fn position(&self) -> usize

Current read cursor position.

Source

pub fn read_u8(&mut self) -> ParseResult<u8>

Read a single byte.

Source

pub fn read_u16_le(&mut self) -> ParseResult<u16>

Read a little-endian u16.

Source

pub fn read_u32_le(&mut self) -> ParseResult<u32>

Read a little-endian u32.

Source

pub fn read_bytes(&mut self, n: usize) -> ParseResult<Vec<u8>>

Read n raw bytes.

Source

pub fn read_cstring(&mut self) -> ParseResult<String>

Read a null-terminated UTF-8 string.

Source

pub fn skip(&mut self, n: usize) -> bool

Skip n bytes.

Source

pub fn reset_cursor(&mut self)

Reset the cursor to the beginning (keeps buffer data).

Source

pub fn compact(&mut self)

Discard already-consumed bytes to free memory.

Source

pub fn parse_count(&self) -> u64

Number of successful parse calls.

Trait Implementations§

Source§

impl Default for StreamParser

Source§

fn default() -> Self

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

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
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.