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
//! SinkEffect trait definition.
use Future;
use crateEffect;
/// An effect that emits items to a sink during execution.
///
/// Unlike `WriterEffect` which accumulates all writes in memory, `SinkEffect`
/// streams items to a provided sink function as they occur, enabling constant
/// memory usage regardless of output volume.
///
/// # When to Use
///
/// - **SinkEffect**: High-volume output, real-time streaming, production logging
/// - **WriterEffect**: Testing, short chains, audit trails needing full history
///
/// # Example
///
/// ```rust
/// use stillwater::effect::sink::prelude::*;
///
/// # tokio_test::block_on(async {
/// let effect = emit::<_, String, ()>("starting".to_string())
/// .and_then(|_| emit("processing".to_string()))
/// .and_then(|_| emit("done".to_string()))
/// .map(|_| 42);
///
/// // Stream to console
/// let result = effect.run_with_sink(&(), |log| async move {
/// println!("{}", log);
/// }).await;
///
/// assert_eq!(result, Ok(42));
/// # });
/// ```