flm_core/core/data/mod.rs
1//! Computed data: the typed tables that pipeline stages write beside the frozen
2//! trees, and the store that holds them during a run.
3//!
4//! A table is typed data that one stage writes beside the frozen trees and other
5//! stages read; its identity is its registered dotted name, never its Rust type,
6//! and that name is also a [capability](crate::core::registry::CapabilityDef),
7//! the capability of the table having been written ([`Table`](table::Table)).
8//! Examples are a map of labels, a set of resolved references, a document-wide
9//! count and an output's artifact set
10//! ([`ArtifactSet`](crate::core::artifact::ArtifactSet)). Tables exist because the document's trees are frozen
11//! once the rewrite stages have run: a stage that runs later cannot write into a
12//! tree, so it records what it computes in a table; see [frozen trees and
13//! computed data](crate::guide::concepts_overview#frozen-trees-and-computed-data).
14//!
15//! The store is a run's collection of computed tables: one writer per table, a
16//! declared write always installs a value, and every read and write is checked
17//! against the stage's declarations at the access site
18//! ([`Computed`](store::Computed)). A [`Run`](crate::core::run::Run) owns one
19//! store; a stage reads it through a checked view and writes into a collector
20//! that the run folds into the store.
21//!
22//! A feature author declares a table with
23//! [`FeatureBuilder::table`](crate::core::registry::FeatureBuilder::table),
24//! implements [`Table`](table::Table) on its value type, and reads and writes it
25//! from a stage through [`StageCx::get`](crate::core::run::StageCx::get) and
26//! [`StageOut::table`](store::StageOut::table). An embedding program reads a
27//! table after a run with [`Run::table`](crate::core::run::Run::table).
28//!
29//! # Module map
30//!
31//! - [`table`]: what a table is and how it is referred to. The trait
32//! [`Table`](table::Table) on a table's value type; the declaration
33//! [`TableDef`](table::TableDef); [`TableType`](table::TableType), a value
34//! type's identity and operations captured for type-erased use; the
35//! registry-assigned number [`TableId`](table::TableId); and the typed table
36//! keys [`TableName<T>`](table::TableName) (a name fixed at compile time) and
37//! [`TableHandle<T>`](table::TableHandle) (a name known only at run time).
38//! - [`store`]: the store and the access to it. [`Computed`](store::Computed),
39//! one version of the store; [`ComputedView`](store::ComputedView), a stage's
40//! read view, checked against the reads the stage declared;
41//! [`StageOut`](store::StageOut), a stage's write collector; and
42//! [`fold_outs`](store::fold_outs), which the runner uses to fold the
43//! collectors into the store.
44//!
45//! The addresses that tables are keyed by,
46//! [`TreeId`](crate::model::addr::TreeId) and
47//! [`NodeAddr`](crate::model::addr::NodeAddr), are defined in
48//! [`crate::model::addr`].
49
50// The crate's module layering, of which this module's position is one line:
51// {model, lang} < core < dump < stdlib < math_passthrough layout standalone
52// This module uses `crate::model` and the diagnostic, span and source aliases of
53// `crate::lang`, and no other submodule of `crate::core`; nothing in
54// `crate::model` or `crate::lang` uses it. It does not depend on any backend nor
55// on `crate::layout`, so that the crate can later be split cheaply. The addresses
56// tables are keyed by belong to `crate::model::addr` so that the tree and
57// document modules can use them without depending on the store. It uses the
58// language's diagnostic types because a stage's output carries its diagnostics
59// beside its data. It is part of `crate::core` because a table is what a stage
60// declares, computes and reads: only the framework and the layers above it use
61// tables.
62
63pub mod store;
64pub mod table;