Skip to main content

ParserSource

Struct ParserSource 

Source
pub struct ParserSource<'s> { /* private fields */ }
Expand description

A tabnas parser applied to one text, as a source.

Implementations§

Source§

impl<'s> ParserSource<'s>

Source

pub fn new(parser: Tabnas, text: &'s str) -> ParserSource<'s>

A source in Materialize mode with default limits, its own abort flag and fresh metrics; the builder methods change each.

Source

pub fn mode(self, mode: SourceMode) -> Self

Source

pub fn grammar(self, name: &str) -> Self

The grammar the parser implements, by the name its crate uses (json for tabnas-json). SourceMode::Incremental runs only for a name capability::incremental lists; with no name, or an unlisted one, ParserSource::run_owned fails with STREAMABILITY_UNKNOWN before parsing. Materialize needs no name.

Source

pub fn unverified(self) -> Self

Run SourceMode::Incremental whatever the verified list says. This exists for the differential suite that maintains the list and for nothing else: on a grammar the suite has not verified, the events may be a well-formed stream of the wrong shape, or malformed, and the run still returns Ok.

Source

pub fn limits(self, limits: Limits) -> Self

Source

pub fn abort(self, abort: AbortFlag) -> Self

Source

pub fn metrics(self, metrics: Arc<Metrics>) -> Self

Source

pub fn run_owned<S: Sink + Send + 'static>( self, sink: S, ) -> (Result<Flow, Fail>, S)

Run with an owned sink, in the configured mode, and hand the sink back with the outcome.

Source

pub fn run_owned_with_value<S: Sink + Send + 'static>( self, sink: S, ) -> (Result<Flow, Fail>, S, Option<Value>)

ParserSource::run_owned, also handing back the value the engine returned, when the parse returned one. In Materialize mode that is the grammar’s value. In Incremental mode it is the engine’s tree AFTER pruning, which is neither the grammar’s value nor the run’s result (the events are): it exists so a test can measure what pruning left in the tree, and nothing else should read it.

Source

pub fn run_boxed( self, sink: Box<dyn Sink + Send>, ) -> (Result<Flow, Fail>, Box<dyn Sink + Send>)

ParserSource::run_owned for a boxed sink.

Trait Implementations§

Source§

impl Source for ParserSource<'_>

Source§

fn run(self, sink: &mut dyn Sink) -> Result<Flow, Fail>

Parse, then walk. A borrowed sink cannot be handed to the engine’s subscriber, so this is the Materialize path whatever the mode; the incremental path is ParserSource::run_owned. The events are the same for a verified grammar; only the retention differs.

Auto Trait Implementations§

§

impl<'s> !Freeze for ParserSource<'s>

§

impl<'s> !RefUnwindSafe for ParserSource<'s>

§

impl<'s> !UnwindSafe for ParserSource<'s>

§

impl<'s> Send for ParserSource<'s>

§

impl<'s> Sync for ParserSource<'s>

§

impl<'s> Unpin for ParserSource<'s>

§

impl<'s> UnsafeUnpin for ParserSource<'s>

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.