borsa_types/attribution.rs
1//! Attribution types for merged history spans.
2
3/// A continuous span of timestamps [start..=end] that a connector contributed.
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub struct Span {
6 /// Inclusive start timestamp (seconds since epoch).
7 pub start: i64,
8 /// Inclusive end timestamp (seconds since epoch).
9 pub end: i64,
10}
11
12/// Attribution of merged history: which connector supplied which timestamp spans.
13///
14/// Behavior:
15/// - Built during history aggregation by tracking de-duplicated candle timestamps
16/// and emitting spans whenever a provider contributes a contiguous range.
17/// - Useful for debugging merge decisions and provider coverage over time.
18#[derive(Debug, Clone, PartialEq, Eq)]
19pub struct Attribution {
20 /// Symbol the attribution refers to.
21 pub symbol: String,
22 /// Collected spans annotated by connector key.
23 pub spans: Vec<(&'static str, Span)>, // (connector_name, span)
24}
25
26impl Attribution {
27 /// Create a new attribution container for a symbol.
28 #[must_use]
29 pub const fn new(symbol: String) -> Self {
30 Self {
31 symbol,
32 spans: vec![],
33 }
34 }
35
36 /// Record a provider span contribution.
37 pub fn push(&mut self, item: (&'static str, Span)) {
38 self.spans.push(item);
39 }
40}