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
// Copyright 2025 Umberto Gotti <umberto.gotti@umbertogotti.dev>
// Licensed under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0
//! Extension trait providing high-level ordered merge for `Timestamped` streams.
//!
//! This trait merges multiple streams of timestamped items, emitting all values from
//! all streams in temporal order. Unlike `combine_latest`, this emits every value
//! from every stream (not just when all have emitted).
//!
//! # Characteristics
//!
//! - **Ordered**: Emits items with smallest timestamp first.
//! - **Fair**: Merges streams fairly assuming they are reasonably synchronized.
//! - **Buffered**: Buffers one item from each stream to determine the minimum timestamp.
//!
//! # Example
//!
//! ```rust
//! use fluxion_stream::OrderedStreamExt;
//! use fluxion_test_utils::{Sequenced, helpers::unwrap_stream, unwrap_value, test_channel};
//! use fluxion_core::Timestamped as TimestampedTrait;
//!
//! # async fn example() {
//! // Create channels
//! let (tx1, stream1) = test_channel::<Sequenced<i32>>();
//! let (tx2, stream2) = test_channel::<Sequenced<i32>>();
//!
//! // Merge streams
//! let mut merged = stream1.ordered_merge(vec![stream2]);
//!
//! // Send values with explicit ordering
//! tx1.unbounded_send((1, 100).into()).unwrap();
//! tx2.unbounded_send((2, 200).into()).unwrap();
//! tx1.unbounded_send((3, 300).into()).unwrap();
//!
//! // Assert - values emitted in temporal order
//! assert_eq!(unwrap_value(Some(unwrap_stream(&mut merged, 500).await)).value, 1);
//! assert_eq!(unwrap_value(Some(unwrap_stream(&mut merged, 500).await)).value, 2);
//! assert_eq!(unwrap_value(Some(unwrap_stream(&mut merged, 500).await)).value, 3);
//! # }
//! ```
pub use ;
pub use ;