1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//! # Sans: Composable Coroutine-Based Programming
//!
//! Build composable computations that can yield intermediate values and be driven
//! to completion by external input.
//!
//! ## Core Traits
//!
//! - **[`Sans<I, O>`]**: Stateful computations that process input and yield values
//! - **[`InitSans<I, O>`]**: Computations that provide initial output before processing input
//!
//! ## Key Features
//!
//! - **Composable**: Chain coroutines together with `.chain()`
//! - **Transformable**: Use `.map_input()`, `.map_yield()`, `.map_done()`
//! - **Async Support**: Both sync and async execution with `handle()` and `handle_async()`
//!
//! ## Example
//!
//! ```
//! use sans::prelude::*;
//!
//! // Build a pipeline that yields initial value, processes input, then finishes
//! let pipeline = init_once(10, |x: i32| x * 2) // Yields 10, then multiplies input by 2
//! .chain(once(|x: i32| x + 1)); // Adds 1 to input, then completes
//!
//! // Drive the pipeline with responses to each yield
//! let result = handle(pipeline, |output| output + 5);
//! ```
//!
//! ## Module Organization
//!
//! This library is organized by capability:
//!
//! - **[`build`]** - Creating new coroutines
//! - **[`compose`]** - Chaining and transforming coroutines
//! - **[`result`]** - Result combinators for error handling in coroutines
//! - **[`poll`]** - Universal adapter implementing both [`Sans`] and [`InitSans`] for bridging APIs
//! - **[`concurrent`]** - Running multiple coroutines concurrently
//! - **[`sequential`]** - Running coroutines one after another
//! - **[`run`]** - Executing coroutine pipelines
//! - **[`iter`]** - Iterator adapters for [`Sans<(), O>`] and [`InitSans<(), O>`]
//! - **[`prelude`]** - Common imports for quick start
//!
//! ## Common Functions
//!
//! **Building Coroutines:**
//! - [`once(f)`](build::once) - Apply function once, then complete
//! - [`repeat(f)`](build::repeat) - Apply function repeatedly
//! - [`init(value, coroutine)`](build::init) - Wrap a `Sans` with an initial output (for `and_then`)
//! - [`init_once(value, f)`](build::init_once) - Yield initial value, then apply function once
//! - [`chain(a, b)`](compose::chain) - Run coroutine `a` to completion, then run coroutine `b`
//!
//! **Execution:**
//! - [`handle(coroutine, responder)`](run::handle) - Drive computation with sync responses
//! - [`handle_async(coroutine, responder)`](run::handle_async) - Drive computation with async responses
// Core modules (essential types)
// Capability modules
// Convenience
// Re-export essential types at root
pub use InitSans;
pub use ;
pub use Step;