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
//! Telemetry adapters bridge real telemetry shapes into [`ResidualSample`].
//!
//! DSFB's core observer accepts immutable [`ResidualSample`] values. In real
//! systems, telemetry often arrives as tracing events, metrics snapshots, or
//! protocol-specific records. [`TelemetryAdapter`] lets library users keep
//! those native types while projecting them into the DSFB residual model.
use crateResidualSample;
/// Adapter from an application-specific telemetry record into a DSFB sample.
///
/// # Example
///
/// ```rust
/// use dsfb_gray::{ResidualSample, ResidualSource, TelemetryAdapter};
///
/// struct LatencyPoint {
/// p95_ns: u64,
/// baseline_ns: u64,
/// ts_ns: u64,
/// }
///
/// struct LatencyAdapter;
///
/// impl TelemetryAdapter<LatencyPoint> for LatencyAdapter {
/// fn adapt(&self, input: &LatencyPoint) -> ResidualSample {
/// ResidualSample {
/// value: input.p95_ns as f64,
/// baseline: input.baseline_ns as f64,
/// timestamp_ns: input.ts_ns,
/// source: ResidualSource::Latency,
/// }
/// }
/// }
/// ```
/// Identity adapter for callers that already hold [`ResidualSample`] values.
;