pub struct InputParser { /* private fields */ }Implementations§
Source§impl InputParser
impl InputParser
pub fn new() -> Self
Sourcepub fn parse<F: FnMut(InputEvent)>(
&mut self,
bytes: &[u8],
callback: F,
maybe_more: bool,
)
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.