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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Copyright 2025 Umberto Gotti <umberto.gotti@umbertogotti.dev>
// Licensed under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0
//! Shared stream subscription factory for Fluxion streams.
//!
//! A [`FluxionShared`] converts a cold stream into a hot, multi-subscriber source.
//! It consumes the original stream and broadcasts each item to all active subscribers.
//!
//! # Runtime Requirements
//!
//! This operator requires one of the following runtime features:
//! - `runtime-tokio` (default)
//! - `runtime-smol`
//! - `runtime-async-std`
//! - Or compiling for `wasm32` target
//!
//! It is not available when compiling without a runtime (no_std + alloc only).
//!
//! ## Alternatives for no_std
//!
//! - Use [`fluxion_core::FluxionSubject`] directly for manual multicast control
//!
//! ## Characteristics
//!
//! - **Hot**: Late subscribers do not receive past items—only items emitted after subscribing.
//! - **Shared execution**: The source stream is consumed once; results are broadcast to all.
//! - **Subscription factory**: Call `subscribe()` to create independent subscriber streams.
//! - **Owned lifecycle**: The forwarding task is owned and cancelled when dropped.
//!
//! ## Example
//!
//! ```rust
//! use fluxion_stream::{IntoFluxionStream, ShareExt, MapOrderedExt, FilterOrderedExt};
//! use fluxion_test_utils::Sequenced;
//!
//! # async fn example() {
//! let (tx, rx) = async_channel::unbounded();
//!
//! // Create a source stream
//! let source = rx.into_fluxion_stream()
//! .map_ordered(|x: Sequenced<i32>| Sequenced::new(x.into_inner() * 2));
//!
//! // Share it among multiple subscribers
//! let shared = source.share();
//!
//! // Each subscriber gets broadcast values, can chain independently
//! let _sub1 = shared.subscribe().unwrap()
//! .filter_ordered(|x| *x > 10);
//!
//! let _sub2 = shared.subscribe().unwrap()
//! .map_ordered(|x: Sequenced<i32>| Sequenced::new(x.into_inner().to_string()));
//! # }
//! ```
//!
//! ## Comparison with FluxionSubject
//!
//! | Type | Source | Push API |
//! |------|--------|----------|
//! | [`fluxion_core::FluxionSubject`] | External (you call `next()`) | Yes |
//! | [`FluxionShared`] | Existing stream | No |
//!
//! Both are subscription factories with the same `subscribe()` pattern.
pub use ;
pub use ;