pub struct StreamParser { /* private fields */ }Expand description
Parses a source that arrives in chunks.
finish returns exactly what parse_bytes returns for
the whole received input, for every chunking: tree, references,
diagnostics and spans. Bytes beyond the mode’s size limit, plus a
three-byte margin for a split UTF-8 character, are counted but not kept;
finish then marks the document shortened, and in program mode refuses
it (E_SOURCE_TOO_LARGE, no nodes), so a program never runs from a
cut-off prefix.
In reply mode, feed also returns a provisional
Revision whenever the drawable picture changes. Programs are not drawn
while streaming: in program mode feed always returns None.
Implementations§
Source§impl StreamParser
impl StreamParser
pub fn new(mode: Mode) -> Self
Sourcepub fn feed(&mut self, chunk: &[u8]) -> Option<Revision>
pub fn feed(&mut self, chunk: &[u8]) -> Option<Revision>
Accepts the next chunk. Returns the new revision when the provisional
picture differs from the last one returned, and None otherwise.
Sourcepub fn revision(&self) -> &Revision
pub fn revision(&self) -> &Revision
The current provisional picture: the last revision feed returned, or
an empty one before any.
Sourcepub fn finish(self) -> Document
pub fn finish(self) -> Document
Parses everything received, exactly as parse_bytes parses it.