Expand description
Streaming transducers over any tabnas parser.
A transducer decides what a source contributes to an output model; a
renderer (the tabnas-render crate) decides how that model becomes
text. This crate is the transducer side:
- the source protocol
JsonEvent(JsonEvents/1) and the push boundarySink; sources that produce it from a parsed value, from a live tabnas parse through the engine’s rule events, or from line-delimited input;Selectors and the matcher and router that recognize selected scopes in one pass and materialize them under a byte limit;- the table protocol
TableEvent(TableRows/1) and the standard metadata-first table transducer; Limits,Metrics,AbortFlagand the stable failureCodes every stage reports.
Everything is synchronous and push-based: the parser calls the first sink from inside its own callback, and a slow writer at the end of the chain slows the parse at the start. That is the backpressure.
The protocol types (events, sinks, tables, failures, limits,
selectors, datums, and the data on either side of a router and of
scan-emit) are tabnas-alchemy’s shared types, tabnas_alchemy::shared,
re-exported here at the paths they have always had. routers()
answers this crate’s implementation of alchemy’s Routers, the
interface a compiled alchemy program makes its routing stages through.
Re-exports§
pub use matcher::Hit;pub use matcher::HitKind;pub use matcher::Matcher;pub use route::Router;pub use routers::routers;pub use routers::TransduceRouters;pub use scan::ScanEmit;pub use source::capability;pub use source::walk_value;pub use source::Guarded;pub use source::ParserSource;pub use source::Prune;pub use source::Source;pub use source::SourceMode;pub use source::ValueSource;pub use table_from_json::TableFromJson;
Modules§
- datum
- The protocol modules, which are alchemy’s shared types. The retained value type.
- error
- The protocol modules, which are alchemy’s shared types. Failures, with stable codes.
- event
- The protocol modules, which are alchemy’s shared types.
JsonEvents/1: the source protocol every transducer consumes. - limits
- The protocol modules, which are alchemy’s shared types. Limits, metrics and cancellation.
- matcher
- Shared-prefix matching of many selectors in one pass.
- route
- Captures: recognize selected scopes and deliver them, complete, in source order.
- routers
- This crate’s implementation of alchemy’s
Routers: the interface a compiled alchemy program makes its routing stages through. - scan
scan-emit: declarative state evolution over a stream.- selector
- The protocol modules, which are alchemy’s shared types. Selectors: reusable descriptions of where in a document to look.
- sink
- The protocol modules, which are alchemy’s shared types. The push boundary between stages.
- source
- Sources: where
JsonEvents/1come from. - table
- The protocol modules, which are alchemy’s shared types.
TableRows/1: one schema, ordered finite rows, completion. - table_
from_ json - The metadata-first table transducer:
JsonEvents/1in,TableRows/1out.
Structs§
- Abort
Flag - A cancellation flag shared by the caller, the source and the stages.
- Bound
Column - A column as the transducer binds it: the public label, and the source path projected from each row. Never crosses into a renderer.
- Budget
- The types on either side of a router, which are alchemy’s shared
types.
The byte budget one materialized capture may not exceed, named after
the
Limitsfield the failure reports. - Capture
Spec - The types on either side of a router, which are alchemy’s shared types. One capture: a tag for the consumer, the selector to match, the mode.
- Count
Sink - A sink that counts events and drops them: the cheapest consumer, for measuring a source on its own.
- Datum
Builder - Builds one
Datumfrom the events of one value, under a byte limit. - Fail
- A failure: a code, and what is known about where and why.
- FnRoute
- The types on either side of a router, which are alchemy’s shared
types.
A route sink made of a closure;
endis a no-op. - FnSink
- A sink made of a closure.
- Limit
- The limit a
Code::ResourceLimitExceedednames. - Limits
- Per-run limits. Every field is named in a failure as written here.
- Metrics
- Counters and high-water marks a run reports. Shared between stages
through an
Arc; every update is one relaxed atomic. - Number
- A number as the source spelled it and as a machine value.
- Path
- A concrete location in a document.
- Public
Column - What a renderer knows about a column.
- Selected
- The types on either side of a router, which are alchemy’s shared types. One completed match.
- Selector
- A description of locations: the root, narrowed step by step.
- Table
- An owned recording of a table, for tests and small results.
- Table
Binding - A table transducer’s source binding.
- Transition
- The result of one step, which is one of alchemy’s shared types. The result of one step: the next state and what to emit for it.
- Tree
Contract - A tree’s events, held to their contract in front of a sink that takes
them as one (a render that writes a document from them): one root
value, and in each object a key and then its value, each key once. A
value walked from a parsed tree keeps it by construction. A parse
streamed as it proceeds may not: it hands on a member its grammar reads
twice (JSON’s
{"a":1,"a":2}, whose value keeps the last) where a tree has one, and the rule-event adapter refuses most shapes it cannot follow but not every one a grammar can produce. A repeated key in one object is refused withDUPLICATE_MEMBER, and events no tree has (a value where a key is due, a key outside an object, a close with nothing open, a second root) withSTREAMABILITY_UNKNOWN, each at the path of the object concerned; the event is not passed on, and what to do then is the host’s (aless falls back once to the parsed value when nothing has been written). Each open object keeps the keys it has had, dropped when it closes, so the cost is a lookup per key and the keys of the objects open at once, which a parse holds in its tree already.
Enums§
- Capture
Mode - The types on either side of a router, which are alchemy’s shared types. What a capture keeps of its match.
- Cell
- One projected value.
- Code
- The stable failure codes.
- Datum
- A retained JSON-like value.
- Duplicates
- How a builder treats a repeated member name.
- Flow
- What a stage wants next.
- Json
Event - One event of
JsonEvents/1. - Missing
Policy - What to do when a row has no value at a column’s path.
- Owned
Json Event JsonEventwith its text owned: what a recorder keeps.- Schema
- Where a table’s columns come from.
- Segment
- One step of a concrete path.
- Step
- One step of a selector.
- Table
Event - One event of
TableRows/1.
Constants§
- VERSION
- This crate’s version, as
Cargo.tomldeclares it.
Traits§
- Route
Sink - The types on either side of a router, which are alchemy’s shared types. The consumer of a router’s matches.
- Sink
- A consumer of
JsonEvents/1. - Table
Sink - A consumer of
TableRows/1.
Functions§
- column_
from_ meta - The standard mapping from a metadata descriptor to a column: the
spec’s
column-from-meta, readingtitleand apathof segments. - replay
- Replay a recording into a sink, stopping where the sink stops.
- walk_
datum - Emit a datum as
JsonEvents/1(without the finalEnd, so a datum can stand in for any part of a document). - write_
json - Append a datum as compact JSON.
- write_
json_ number - Append a number: its lexeme when known, else the shortest text that
reads back as the same f64. A non-finite value has no JSON form and is
written as
null; renderers reject it before it gets here. - write_
json_ string - Append
sas a JSON string literal, escaped as RFC 8259 requires:"and\\escaped, control characters as\\uXXXX(with the short forms for\\b \\f \\n \\r \\t), everything else as itself.
Type Aliases§
- Capture
Id - Which selector matched: its position in the slice given to
Matcher::new. One of alchemy’s shared types. Which selector matched: its position in the slice given to transduce’sMatcher::new. - Column
Mapper - Maps one metadata descriptor to a bound column.