[go: up one dir, main page]

InputParser

Struct InputParser 

Source
pub struct InputParser { /* private fields */ }

Implementations§

Source§

impl InputParser

Source

pub fn new() -> Self

Source

pub fn parse<F: FnMut(InputEvent)>( &mut self, bytes: &[u8], callback: F, maybe_more: bool, )

Push a sequence of bytes into the parser. Each time input is recognized, the provided callback will be passed the decoded InputEvent. If not enough data are available to fully decode a sequence, the remaining data will be buffered until the next call. The maybe_more flag controls how ambiguous partial sequences are handled. The intent is that maybe_more should be set to true if you believe that you will be able to provide more data momentarily. This will cause the parser to defer judgement on partial prefix matches. You should attempt to read and pass the new data in immediately afterwards. If you have attempted a read and no data is immediately available, you should follow up with a call to parse with an empty slice and maybe_more=false to allow the partial data to be recognized and processed.

Source

pub fn parse_as_vec( &mut self, bytes: &[u8], maybe_more: bool, ) -> Vec<InputEvent>

Trait Implementations§

Source§

impl Debug for InputParser

Source§

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

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

impl Default for InputParser

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.