grafos_stream/
lib.rs

1//! Stream processing pipelines over fabric resources.
2//!
3//! This crate provides a pipeline builder DSL for composing data processing
4//! stages (`Source` → `Transform` → `Sink`/`Fold`) that communicate through
5//! [`FabricQueue`](grafos_collections::queue::FabricQueue) inter-stage buffers
6//! backed by leased fabric memory.
7//!
8//! # Stage traits
9//!
10//! | Trait | Role |
11//! |-------|------|
12//! | [`Source<T>`](stage::Source) | Produces items (returns `None` when exhausted) |
13//! | [`Transform<In, Out>`](stage::Transform) | Transforms one item to zero or one output items |
14//! | [`Sink<T>`](stage::Sink) | Consumes items (terminal stage) |
15//! | [`Fold<T, Acc>`](stage::Fold) | Reduces items into an accumulator (terminal stage) |
16//!
17//! # Pipeline builder
18//!
19//! ```rust
20//! use grafos_stream::prelude::*;
21//!
22//! # grafos_std::host::reset_mock();
23//! # grafos_std::host::mock_set_fbmu_arena_size(65536);
24//! let source = VecSource::new(vec![1u32, 2, 3, 4, 5]);
25//! let result = Pipeline::from_source(source)
26//!     .map(|x| x * 2)
27//!     .filter(|x| *x > 4)
28//!     .collect()
29//!     .run()?;
30//! assert_eq!(result, vec![6, 8, 10]);
31//! # Ok::<(), grafos_std::FabricError>(())
32//! ```
33//!
34//! # Feature flags
35//!
36//! | Feature | Default | Effect |
37//! |---------|---------|--------|
38//! | `std` | Yes | Enables `std` in grafos-std |
39//! | `checkpoint` | No | Block-backed stage checkpointing |
40
41#![cfg_attr(not(feature = "std"), no_std)]
42
43extern crate alloc;
44
45pub mod pipeline;
46pub mod placement;
47pub mod sink;
48pub mod source;
49pub mod stage;
50
51#[cfg(feature = "checkpoint")]
52pub mod checkpoint;
53
54pub mod prelude {
55    pub use crate::pipeline::Pipeline;
56    pub use crate::placement::NodeConstraint;
57    pub use crate::sink::{CollectSink, CountSink, FnSink};
58    pub use crate::source::{IterSource, VecSource};
59    pub use crate::stage::{Fold, Sink, Source, Transform};
60}