pub struct Program { /* private fields */ }Expand description
A compiled program: parsed, desugared, resolved and checked, with its
plan built. Cheap to clone; Send + Sync.
Implementations§
Source§impl Program
impl Program
Sourcepub fn with_duplicates(&self, duplicates: Duplicates) -> Result<Program, Fail>
pub fn with_duplicates(&self, duplicates: Duplicates) -> Result<Program, Fail>
The same program with another policy for repeated member names in captured values; the default rejects them.
Sourcepub fn with_abort(&self, abort: AbortFlag) -> Program
pub fn with_abort(&self, abort: AbortFlag) -> Program
The same program with the host’s cancellation: every sink it makes
reads the flag as the program’s functions run, so a timeout stops
a long computation on one item with ABORTED rather than waiting
for the item to finish. The source takes the same flag
(ParserSource::abort) to stop between events.
Sourcepub fn duplicates(&self) -> Duplicates
pub fn duplicates(&self) -> Duplicates
The policy for a member name repeated in a captured scope.
Sourcepub fn input(&self) -> Input
pub fn input(&self) -> Input
What the host declared export’s input to be, and so which sink
it pushes the source into: Program::sink for JSON events,
Program::parser_sink for parser events.
Sourcepub fn file(&self) -> &str
pub fn file(&self) -> &str
The file name the program was compiled under: the first, of several.
pub fn resolved(&self) -> &Arc<Resolved> ⓘ
Sourcepub fn output(&self) -> Output
pub fn output(&self) -> Output
What the program produces, and so what the host renders: decided
by the checker from export’s type.
Sourcepub fn plan_output(&self) -> Output
pub fn plan_output(&self) -> Output
The protocol the built plan produces; the checker’s output agrees
with it, and a test holds the two together. A stream of items is
the checker’s to name (every item an event, or a table event),
since the runtime learns an item’s shape only as it arrives.
Sourcepub fn row_selector(&self) -> Option<&Selector>
pub fn row_selector(&self) -> Option<&Selector>
The selector under which the source is read one row at a time,
when the plan makes one known: the table binding’s :rows, a
select’s selector, or the one multi-location capture of a
route. A host that streams a verified grammar prunes the parse
under it.
Sourcepub fn explain(&self) -> String
pub fn explain(&self) -> String
The plan report of spec section 15.5: the chain of calls, the protocols, what is retained and under which limits, the ordering contract, the renderer, the guarantee and its qualification.
Sourcepub fn explain_json(&self) -> Value
pub fn explain_json(&self) -> Value
The same report as one JSON object, for a host’s --explain.
Sourcepub fn sink(
&self,
out: Box<dyn Write + Send>,
render: Option<Renderer>,
limits: &Limits,
metrics: Arc<Metrics>,
) -> Result<Box<dyn Sink + Send>, Fail>
pub fn sink( &self, out: Box<dyn Write + Send>, render: Option<Renderer>, limits: &Limits, metrics: Arc<Metrics>, ) -> Result<Box<dyn Sink + Send>, Fail>
The sink for one run: the host pushes the source’s events into it
and one End, and the output reaches out through a coalescing
writer (Renderers::write_out) with limits.max_output_bytes
enforced and output_bytes counted in metrics. render chooses
how a table or JSON-events result is rendered (CSV or JSON; None
for the default); a program that renders its own text takes none
(render_of_text). A program compiled over parser events takes
them through Program::parser_sink instead.
Sourcepub fn sink_out(
&self,
out: Box<dyn TextOut + Send>,
render: Option<Renderer>,
limits: &Limits,
metrics: Arc<Metrics>,
) -> Result<EventSink, Fail>
pub fn sink_out( &self, out: Box<dyn TextOut + Send>, render: Option<Renderer>, limits: &Limits, metrics: Arc<Metrics>, ) -> Result<EventSink, Fail>
Program::sink over any text output: for a host that has its own
writer stage, and for tests that read the text back.
Sourcepub fn parser_sink(
&self,
out: Box<dyn Write + Send>,
render: Option<Renderer>,
limits: &Limits,
metrics: Arc<Metrics>,
) -> Result<Box<dyn ParserSink + Send>, Fail>
pub fn parser_sink( &self, out: Box<dyn Write + Send>, render: Option<Renderer>, limits: &Limits, metrics: Arc<Metrics>, ) -> Result<Box<dyn ParserSink + Send>, Fail>
The sink for one run over parser events, for a program compiled
over Input::ParserEvents: the host pushes each rule pass into
it and one End, once the parse has returned its value. The output
is written as for Program::sink.
Sourcepub fn parser_sink_out(
&self,
out: Box<dyn TextOut + Send>,
render: Option<Renderer>,
limits: &Limits,
metrics: Arc<Metrics>,
) -> Result<Box<dyn ParserSink + Send>, Fail>
pub fn parser_sink_out( &self, out: Box<dyn TextOut + Send>, render: Option<Renderer>, limits: &Limits, metrics: Arc<Metrics>, ) -> Result<Box<dyn ParserSink + Send>, Fail>
Program::parser_sink over any text output, as
Program::sink_out is Program::sink’s.
Sourcepub fn parser_sink_into(
&self,
down: Box<dyn Sink + Send>,
limits: &Limits,
metrics: Arc<Metrics>,
) -> Result<Box<dyn ParserSink + Send>, Fail>
pub fn parser_sink_into( &self, down: Box<dyn Sink + Send>, limits: &Limits, metrics: Arc<Metrics>, ) -> Result<Box<dyn ParserSink + Send>, Fail>
The sink for one run over parser events whose JSON events go into
the host’s own down rather than to a renderer, for a program
compiled over Input::ParserEvents that answers JSON events: a
format’s transducer part, run in front of the host’s own stages (a
renderer of its own, a scope over a path, another program’s sink).
The host pushes each rule pass into the ParserSink + Send it
returns, then one ParserEvent::End once the parse has returned its
value, and down takes the events as the program makes them, then
one End. The source’s limits hold on them as on a source’s own. A
program that answers a text or a table is refused
(protocol_mismatch) before anything runs, as is one compiled over
JSON events.