1use std::fmt;
2
3use crate::{time::SystemInstant, Measurement};
4
5#[cfg(feature = "register-recorder")]
6pub mod recorder;
7
8pub type IndexValue = u64;
12
13#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct Index(IndexValue);
16
17impl Index {
18 #[must_use]
19 pub const fn new(value: IndexValue) -> Self {
20 Self(value)
21 }
22
23 #[must_use]
24 pub const fn to_value(self) -> IndexValue {
25 let Index(value) = self;
26 value
27 }
28}
29
30impl From<IndexValue> for Index {
31 fn from(from: IndexValue) -> Self {
32 Self::new(from)
33 }
34}
35
36impl From<Index> for IndexValue {
37 fn from(from: Index) -> Self {
38 from.to_value()
39 }
40}
41
42impl fmt::Display for Index {
43 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
44 write!(f, "#{}", self.to_value())
46 }
47}
48
49#[derive(Debug, Clone, Eq, PartialEq)]
51pub struct IndexedMeasurement<Value> {
52 pub index: Index,
53 pub measurement: Measurement<Value>,
54}
55
56#[derive(Debug, Clone, Eq, PartialEq)]
58pub struct ObservedValue<Value> {
59 pub observed_at: SystemInstant,
60 pub value: Value,
61}
62
63#[derive(Debug, Clone, Eq, PartialEq)]
69pub struct ObservedValues<Value> {
70 pub observed_at: SystemInstant,
71 pub values: Vec<Option<Value>>,
72}