pipeline/lib.rs
1//! Core value layer shared by the pipeline front-ends.
2//!
3//! This crate (imported as `pipeline`) provides the dirty/validity-tracking
4//! value types — [`value::Value`], [`value::Vector`], [`value::Buckets`] — and
5//! the [`Reset`] trait the engines use to clear per-cycle state. It contains no
6//! macros and no graph machinery; the static (`pipeline-dsl`) and dynamic
7//! (`pipeline-graph`) front-ends are built on top of it.
8#![warn(missing_docs)]
9
10pub mod value;
11
12/// Convenience root re-exports so callers can write `pipeline::Vector` etc.
13/// (the canonical paths under `pipeline::value::*` remain available too).
14pub use value::{Buckets, Value, Vector};
15
16use thiserror::Error;
17
18/// Errors produced by the value layer.
19#[derive(Error, Debug, PartialEq)]
20pub enum Error {
21 /// A value was read while uninitialised (no value held).
22 #[error("accessing uninitialised value")]
23 UninitialisedValue,
24}
25
26/// Clears a value's **per-cycle dirty state** (contents and validity are
27/// preserved). The pipeline engines call this at the end of each `compute()`
28/// on written and externally-fed nodes.
29pub trait Reset {
30 /// Error type returned by [`Reset::reset`].
31 type Error;
32 /// Clear per-cycle dirty state.
33 fn reset(&mut self) -> Result<(), Self::Error>;
34}
35
36/// Query a value's **per-cycle dirty state**: whether it changed this cycle
37/// (written *or* invalidated). The pipeline engines use this to decide whether a
38/// stage has any fresh input. The read-side mirror of [`Reset`].
39pub trait Updated {
40 /// Whether the value changed this cycle.
41 fn is_updated(&self) -> bool;
42}
43
44/// Per-stage execution counters, shared by both front-ends' optional stats
45/// support (`pipeline-graph`'s `Pipeline::stats`, `pipeline-dsl`'s
46/// `#[pipeline(stats)]`). Stored contiguously and handed out by reference, so
47/// reading them costs nothing regardless of how this struct grows.
48#[derive(Clone, Debug, PartialEq, Eq, Default)]
49pub struct StageStats {
50 /// Stage name.
51 pub name: String,
52 /// Number of cycles the stage actually ran.
53 pub ran: u64,
54 /// Number of cycles the stage was skipped because no input was dirty
55 /// (only possible for `skip_when_clean` stages).
56 pub skipped: u64,
57 /// Total wall-clock time spent running the stage.
58 pub time: std::time::Duration,
59}