sayiir_core/lib.rs
1//! Core types and traits for the Sayiir durable workflow engine.
2//!
3//! This crate defines the foundational abstractions that every other `sayiir-*`
4//! crate builds on. It is intentionally **runtime-agnostic** — no persistence,
5//! no execution strategy, just pure workflow modelling.
6//!
7//! # Key Abstractions
8//!
9//! | Type / Trait | Purpose |
10//! |---|---|
11//! | [`Workflow`] / [`SerializableWorkflow`] | The continuation tree that describes *what* to execute |
12//! | [`WorkflowBuilder`] | Fluent builder for assembling sequential, forked, and joined pipelines |
13//! | [`CoreTask`] | Trait implemented by every task (input → output, with metadata) |
14//! | [`Codec`] | Trait for pluggable serialization (JSON, rkyv, …) |
15//! | [`WorkflowContext`] | Per-execution context carrying the codec, workflow ID, and user metadata |
16//! | [`WorkflowSnapshot`](snapshot::WorkflowSnapshot) | Checkpoint of in-flight execution state (completed tasks + outputs) |
17//! | [`TaskRegistry`] | Name → factory map used for deserializing workflows across process boundaries |
18//!
19//! # Architecture
20//!
21//! ```text
22//! sayiir-core (this crate — types & traits only)
23//! ↑
24//! sayiir-persistence (SnapshotStore, SignalStore, TaskClaimStore)
25//! ↑
26//! sayiir-runtime (CheckpointingRunner, PooledWorker, execution loop)
27//! ↑
28//! sayiir-macros (#[task], workflow! — optional convenience)
29//! ```
30//!
31//! # Quick Example
32//!
33//! ```rust,ignore
34//! use sayiir_core::prelude::*;
35//! use std::sync::Arc;
36//!
37//! // Create a context (codec + workflow ID)
38//! // (Codec is generic — bring your own or use sayiir-runtime's JsonCodec / RkyvCodec)
39//! let ctx = WorkflowContext::new("order-pipeline", Arc::new(my_codec), Arc::new(()));
40//!
41//! // Build a workflow: validate → charge
42//! let wf = WorkflowBuilder::new(ctx)
43//! .then("validate", |order: String| async move { Ok(order) })
44//! .then("charge", |order: String| async move { Ok(42u64) })
45//! .build()?;
46//! ```
47//!
48//! For the proc-macro experience (`#[task]` + `workflow!`), see
49//! [`sayiir-macros`](https://docs.rs/sayiir-macros).
50//!
51//! [`Workflow`]: workflow::Workflow
52//! [`SerializableWorkflow`]: workflow::SerializableWorkflow
53//! [`WorkflowBuilder`]: builder::WorkflowBuilder
54//! [`CoreTask`]: task::CoreTask
55//! [`Codec`]: codec::Codec
56//! [`WorkflowContext`]: context::WorkflowContext
57//! [`TaskRegistry`]: registry::TaskRegistry
58
59#![deny(clippy::pedantic)]
60#![forbid(unsafe_code)]
61#![deny(
62 clippy::unwrap_used,
63 clippy::expect_used,
64 clippy::panic,
65 clippy::indexing_slicing,
66 clippy::todo,
67 clippy::unimplemented,
68 clippy::dbg_macro,
69 clippy::print_stdout,
70 clippy::print_stderr
71)]
72
73pub mod branch_results;
74pub mod builder;
75pub mod codec;
76pub mod context;
77pub mod error;
78pub mod prelude;
79pub mod registry;
80pub mod snapshot;
81pub mod task;
82pub mod task_claim;
83pub mod workflow;