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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
//! Unified single-pass pcap stream — flow lifecycle **and** typed
//! parser messages from one iterator (issue #111).
//!
//! [`session_messages`](crate::pcap::session_messages) yields only the
//! parser's messages; [`Driver::run_pcap`](crate::driver::Driver::run_pcap)
//! yields only the flow lifecycle (messages drain from a separate
//! [`SlotHandle`](crate::driver::SlotHandle), with a trailing-drain
//! footgun — the close-flush batch lands in the slot *after* the event
//! iterator ends). For a single parser, [`session_pulses`] /
//! [`datagram_pulses`] interleave both into one ordered [`Pulse`]
//! stream, so a `Started → Message* → Ended` story arrives in one loop
//! with nothing left buffered.
//!
//! ```no_run
//! use flowscope::pcap::Pulse;
//! use flowscope::tls::TlsParser;
//!
//! for pulse in flowscope::pcap::session_pulses::<TlsParser>("trace.pcap")? {
//! match pulse {
//! Pulse::Started { key, .. } => println!("flow up: {key:?}"),
//! Pulse::Message(m) => println!(" msg on {:?}: {:?}", m.key, m.message),
//! Pulse::Ended { key, reason, .. } => println!("flow down: {key:?} ({reason:?})"),
//! _ => {}
//! }
//! }
//! # Ok::<(), flowscope::Error>(())
//! ```
use Path;
use crateSlotMessage;
use crate;
use crate;
use crateL4Proto;
use cratePcapFlowSource;
use crateSessionEvent;
use crate::;
/// One item in a unified [`session_pulses`] / [`datagram_pulses`]
/// stream: either a flow-lifecycle marker or a typed parser message,
/// delivered in wire order for a single parser.
///
/// The lifecycle subset mirrors the offline engine's stream
/// (`Started` / `Ended` / `Tick`); per-packet `Packet` / `Established`
/// events are not surfaced here — reach for
/// [`Driver`](crate::driver::Driver) when you need those. `Message`
/// reuses the same [`SlotMessage`] a driver slot drains, so the
/// message + `side` + `ts` are identical to the typed-driver path.
///
/// `#[non_exhaustive]` — matching should carry a wildcard arm.
/// Replay a pcap through a single [`SessionParser`] `P`, yielding one
/// ordered [`Pulse`] stream of flow lifecycle **and** typed messages
/// (issue #111).
///
/// The TCP counterpart of [`datagram_pulses`]. Where
/// [`session_messages`](crate::pcap::session_messages) yields messages
/// only and [`Driver::run_pcap`](crate::driver::Driver::run_pcap) yields
/// lifecycle only, this delivers both in one loop in wire order —
/// close-flush messages land as `Message` pulses before the flow's
/// `Ended`, so nothing is left buffered when the iterator ends.
///
/// Uses the bidirectional 5-tuple extractor; keys are [`FiveTupleKey`].
/// For multiple parsers at once, stay on
/// [`Driver::run_pcap`](crate::driver::Driver::run_pcap).
///
/// ```no_run
/// use flowscope::pcap::Pulse;
/// use flowscope::http::HttpParser;
///
/// for pulse in flowscope::pcap::session_pulses::<HttpParser>("trace.pcap")? {
/// if let Pulse::Message(m) = pulse {
/// println!("{:?}: {:?}", m.key, m.message);
/// }
/// }
/// # Ok::<(), flowscope::Error>(())
/// ```
/// The [`DatagramParser`] (UDP) mirror of [`session_pulses`] — one
/// ordered [`Pulse`] stream of flow lifecycle + typed messages for a
/// single datagram parser (issue #111).
///
/// ```no_run
/// use flowscope::pcap::Pulse;
/// use flowscope::dns::DnsUdpParser;
///
/// for pulse in flowscope::pcap::datagram_pulses::<DnsUdpParser>("trace.pcap")? {
/// if let Pulse::Message(m) = pulse {
/// println!("{:?}: {:?}", m.key, m.message);
/// }
/// }
/// # Ok::<(), flowscope::Error>(())
/// ```