pub struct Parser { /* private fields */ }Expand description
Implementations§
Source§impl Parser
impl Parser
Sourcepub fn is_ground(&self) -> bool
pub fn is_ground(&self) -> bool
True when no escape sequence or string is in progress: the next byte
starts fresh. A consumer that snapshots its own state (a terminal
checkpoint) can do so here without saving the parser’s internals,
because a fresh Parser is then indistinguishable from this one.
UTF-8 is not the parser’s concern in feed_with
(text arrives as raw bytes); a caller decoding text checks its
Utf8Decoder as well.
Sourcepub fn feed_with<F: FnMut(Event<'_>)>(&mut self, input: &[u8], f: F)
pub fn feed_with<F: FnMut(Event<'_>)>(&mut self, input: &[u8], f: F)
Tokenize input, calling f once per Event, allocating nothing.
Partial sequences are held for the next call. A text run in progress is always delivered before returning, so no input byte is buffered except inside an unfinished escape sequence.
Sourcepub fn feed(&mut self, input: &[u8]) -> Vec<Token>
pub fn feed(&mut self, input: &[u8]) -> Vec<Token>
Feed a chunk of bytes; returns the tokens completed by this chunk.
Any accumulated text run is flushed at the end of the call; partial
escape sequences and partial UTF-8 characters are held for the next.
This is feed_with with the events copied into
owned Tokens; prefer the engine where the allocation matters.