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
use super::*;
#[derive(Copy, Clone, Debug)]
pub struct UnitError;
impl std::error::Error for UnitError {}
impl std::fmt::Display for UnitError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
f.write_fmt(format_args!("{:?}", self))
}
}
pub struct FakeBmeSensor {
measurement: nb::Result<Vec<Input>, UnitError>,
}
impl FakeBmeSensor {
pub fn new(measurement: nb::Result<Vec<Input>, UnitError>) -> Self {
Self { measurement }
}
}
impl Default for FakeBmeSensor {
fn default() -> Self {
Self::new(Ok(vec![]))
}
}
impl BmeSensor for FakeBmeSensor {
type Error = UnitError;
fn start_measurement(
&mut self,
_: &BmeSettingsHandle<'_>,
) -> Result<std::time::Duration, UnitError> {
Ok(std::time::Duration::new(0, 0))
}
fn get_measurement(&mut self) -> nb::Result<Vec<Input>, UnitError> {
self.measurement.clone()
}
}