Skip to main content

tabnas_transduce/
lib.rs

1//! Streaming transducers over any tabnas parser.
2//!
3//! A transducer decides what a source contributes to an output model; a
4//! renderer (the `tabnas-render` crate) decides how that model becomes
5//! text. This crate is the transducer side:
6//!
7//! - the source protocol [`JsonEvent`] (`JsonEvents/1`) and the push
8//!   boundary [`Sink`];
9//! - [`source`]s that produce it from a parsed value, from a live tabnas
10//!   parse through the engine's rule events, or from line-delimited input;
11//! - [`Selector`]s and the matcher and router that recognize selected
12//!   scopes in one pass and materialize them under a byte limit;
13//! - the table protocol [`TableEvent`] (`TableRows/1`) and the standard
14//!   metadata-first table transducer;
15//! - [`Limits`], [`Metrics`], [`AbortFlag`] and the stable failure
16//!   [`Code`]s every stage reports.
17//!
18//! Everything is synchronous and push-based: the parser calls the first
19//! sink from inside its own callback, and a slow writer at the end of the
20//! chain slows the parse at the start. That is the backpressure.
21//!
22//! The protocol types (events, sinks, tables, failures, limits,
23//! selectors, datums, and the data on either side of a router and of
24//! `scan-emit`) are tabnas-alchemy's shared types, `tabnas_alchemy::shared`,
25//! re-exported here at the paths they have always had. [`routers()`]
26//! answers this crate's implementation of alchemy's `Routers`, the
27//! interface a compiled alchemy program makes its routing stages through.
28
29#![forbid(unsafe_code)]
30
31/// The README's Rust example runs as a doctest, so a stale one fails the
32/// gate rather than misleading the reader.
33#[cfg(doctest)]
34#[doc = include_str!("../README.md")]
35mod readme_examples {}
36
37pub mod matcher;
38pub mod route;
39pub mod routers;
40pub mod scan;
41pub mod source;
42pub mod table_from_json;
43
44/// The protocol modules, which are alchemy's shared types.
45pub use tabnas_alchemy::shared::{datum, error, event, limits, selector, sink, table};
46
47pub use datum::{
48    walk_datum, write_json, write_json_number, write_json_string, Datum, DatumBuilder, Duplicates,
49};
50pub use error::{Code, Fail, Limit};
51pub use event::{JsonEvent, Number, OwnedJsonEvent};
52pub use limits::{AbortFlag, Limits, Metrics};
53pub use matcher::{CaptureId, Hit, HitKind, Matcher};
54pub use route::{Budget, CaptureMode, CaptureSpec, FnRoute, RouteSink, Router, Selected};
55pub use routers::{routers, TransduceRouters};
56pub use scan::{ScanEmit, Transition};
57pub use selector::{Path, Segment, Selector, Step};
58pub use sink::{replay, CountSink, Flow, FnSink, Sink, TreeContract};
59pub use source::{
60    capability, walk_value, Guarded, ParserSource, Prune, Source, SourceMode, ValueSource,
61};
62pub use table::{
63    column_from_meta, BoundColumn, Cell, ColumnMapper, MissingPolicy, PublicColumn, Schema, Table,
64    TableBinding, TableEvent, TableSink,
65};
66pub use table_from_json::TableFromJson;
67
68/// This crate's version, as `Cargo.toml` declares it.
69pub const VERSION: &str = env!("CARGO_PKG_VERSION");