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
//! Streams: a pull-based, chunked [`Stream`], its consumers
//! ([`Sink`]), producer-fed streams ([`stream_from_channel`] / [`StreamSender`]), and the
//! stream-, sink- and fold-backed channels ([`StreamChannel`], [`FoldChannel`],
//! `Channel::to_stream` / `to_sink`).
//!
//! | 0.6 (`id_effect::streaming`) | 0.7 |
//! |---|---|
//! | `Arc<Mutex<StreamState>>`, locked on every pull | an owned pull: the rest of the stream is returned with each chunk, no lock |
//! | `poll_next_chunk(&mut self, &mut env)` | [`Stream::next_chunk`]`(self)` → `Effect<Option<(Chunk, Stream)>>` |
//! | `map_effect`: concurrent within a chunk (admission budget), `Or<E, E2>` errors, one `R` clone per element | [`Stream::map_effect`]: sequential, same `E`, no `R` clone |
//! | — | [`Stream::map_effect_par`]`(n, f)`: at most `n` in flight, ordered output |
//! | `StreamSender::fail` spinning on a full queue | [`StreamSender::fail`] never waits (failure slot + queue shutdown) |
//! | `Channel::from_stream` / `from_fold` / `from_sink` | [`StreamChannel`] / [`FoldChannel::from_fold`] / [`FoldChannel::from_sink`] |
//! | `with_throughput_metric(Metric)` | [`Stream::with_throughput_counter`]`(Arc<AtomicU64>)` |
//!
//! Every operator pulls one upstream chunk per downstream pull, so memory stays proportional to
//! the chunk size (plus documented operator state) and infinite sources work. [`Chunk`] and
//! [`Transducer`] are kernel-independent.
//!
//! ```
//! use id_effect::{Stream, succeed};
//! use id_effect::Never;
//!
//! // Sequential effectful map, then a bounded-concurrency one.
//! let out = Stream::<u32, Never>::from_iterable(1..=5)
//! .map_effect(|n| succeed(n * 10))
//! .map_effect_par(2, |n| succeed(n + 1))
//! .run_collect()
//! .block_on()
//! .into_result();
//! assert_eq!(out.ok(), Some(vec![11, 21, 31, 41, 51]));
//! ```
pub use ;
pub use ;
pub use Chunk;
pub use ;
pub use ;
pub use Sink;
pub use ;
pub use ;
pub use ;
pub use window_instant;