Skip to main content

StreamParser

Struct StreamParser 

Source
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

Source

pub fn new(mode: Mode) -> Self

Source

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.

Source

pub fn revision(&self) -> &Revision

The current provisional picture: the last revision feed returned, or an empty one before any.

Source

pub fn work(&self) -> Work

The work the last feed call did.

Source

pub fn finish(self) -> Document

Parses everything received, exactly as parse_bytes parses it.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.