pub struct ParserSource<'s> { /* private fields */ }Expand description
A tabnas parser applied to one text, as a source.
Implementations§
Source§impl<'s> ParserSource<'s>
impl<'s> ParserSource<'s>
Sourcepub fn new(parser: Tabnas, text: &'s str) -> ParserSource<'s>
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.
pub fn mode(self, mode: SourceMode) -> Self
Sourcepub fn grammar(self, name: &str) -> Self
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.
Sourcepub fn unverified(self) -> Self
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.
pub fn limits(self, limits: Limits) -> Self
pub fn abort(self, abort: AbortFlag) -> Self
pub fn metrics(self, metrics: Arc<Metrics>) -> Self
Sourcepub fn run_owned<S: Sink + Send + 'static>(
self,
sink: S,
) -> (Result<Flow, Fail>, S)
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.
Sourcepub fn run_owned_with_value<S: Sink + Send + 'static>(
self,
sink: S,
) -> (Result<Flow, Fail>, S, Option<Value>)
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.
Trait Implementations§
Source§impl Source for ParserSource<'_>
impl Source for ParserSource<'_>
Source§fn run(self, sink: &mut dyn Sink) -> Result<Flow, Fail>
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.