frequenz_microgrid/
sample.rs1use chrono::{DateTime, Utc};
5
6#[derive(Copy, Clone, Debug, Default)]
8pub struct Sample<Q: Copy + Clone + std::fmt::Debug + Default> {
9 pub(crate) timestamp: DateTime<Utc>,
10 pub(crate) value: Option<Q>,
11}
12
13impl<Q: Copy + Clone + Default + std::fmt::Debug> frequenz_resampling::Sample for Sample<Q> {
14 type Value = Q;
15
16 fn new(timestamp: DateTime<Utc>, value: Option<Self::Value>) -> Self {
17 Self { timestamp, value }
18 }
19
20 fn timestamp(&self) -> DateTime<Utc> {
21 self.timestamp
22 }
23
24 fn value(&self) -> Option<Self::Value> {
25 self.value
26 }
27}
28
29impl<Q: Copy + Clone + Default + std::fmt::Debug> Sample<Q> {
30 pub fn new(timestamp: DateTime<Utc>, value: Option<Q>) -> Self {
32 Self { timestamp, value }
33 }
34
35 pub fn timestamp(&self) -> DateTime<Utc> {
37 self.timestamp
38 }
39
40 pub fn value(&self) -> Option<Q> {
42 self.value
43 }
44}