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
// Copyright 2025 Umberto Gotti <umberto.gotti@umbertogotti.dev>
// Licensed under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0
//! Map ordered operator - transforms stream items while preserving temporal ordering.
//!
//! The [`map_ordered`](MapOrderedExt::map_ordered) operator applies a transformation function
//! to each item in the stream while maintaining the original temporal ordering.
//!
//! ## Characteristics
//!
//! - **Chainable**: Returns a stream that can be further chained
//! - **Timestamp-preserving**: Original timestamps are maintained
//! - **Lazy**: Transformations are applied only when items are polled
//! - **Type-flexible**: Can transform between different types
//! - **Error-passthrough**: Errors pass through unchanged
//!
//! ## Example
//!
//! ```rust
//! use fluxion_stream::{IntoFluxionStream, MapOrderedExt};
//! use fluxion_test_utils::Sequenced;
//! use futures::StreamExt;
//!
//! # async fn example() {
//! let (tx, rx) = async_channel::unbounded();
//!
//! // Transform integers to their doubles
//! let mut stream = rx.into_fluxion_stream()
//! .map_ordered(|n: Sequenced<i32>| Sequenced::new(n.into_inner() * 2));
//!
//! tx.try_send(Sequenced::new(1)).unwrap();
//! tx.try_send(Sequenced::new(2)).unwrap();
//! tx.try_send(Sequenced::new(3)).unwrap();
//! drop(tx);
//!
//! assert_eq!(stream.next().await.unwrap().unwrap().into_inner(), 2);
//! assert_eq!(stream.next().await.unwrap().unwrap().into_inner(), 4);
//! assert_eq!(stream.next().await.unwrap().unwrap().into_inner(), 6);
//! # }
//! ```
//!
//! ## Use Cases
//!
//! - **Data transformation**: Convert between types or modify values
//! - **Normalization**: Scale or adjust values consistently
//! - **Extraction**: Pull specific fields from complex types
//! - **Enrichment**: Add computed properties to data
pub use MapOrderedExt;
pub use MapOrderedExt;