Skip to main content

Program

Struct Program 

Source
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

Source

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.

Source

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.

Source

pub fn duplicates(&self) -> Duplicates

The policy for a member name repeated in a captured scope.

Source

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.

Source

pub fn file(&self) -> &str

The file name the program was compiled under: the first, of several.

Source

pub fn resolved(&self) -> &Arc<Resolved> ⓘ

Source

pub fn result(&self) -> &Val

The plan export answered: a text or a stream.

Source

pub fn output(&self) -> Output

What the program produces, and so what the host renders: decided by the checker from export’s type.

Source

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.

Source

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.

Source

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.

Source

pub fn explain_json(&self) -> Value

The same report as one JSON object, for a host’s --explain.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Program

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Program

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.