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
53
54
55
56
57
58
59
60
61
62
63
64
//! The single seam between the dashboard and whatever produces its data.
//!
//! A real node and the [`Mock`](crate::Mock) both implement [`StateSource`], so the
//! serving layer never knows which it is talking to. What you design and debug against
//! the mock on a laptop is exactly what ships against real sensors.
use crate;
use crateState;
/// Produces the current [`State`] snapshot whenever the dashboard asks for one.
///
/// The serving layer calls [`snapshot`](StateSource::snapshot) to answer `GET /state`
/// and again on each live-update tick, so an implementation should return the latest
/// view of the node cheaply. It takes `&mut self` so a source may advance internal
/// state (a mock its clock, a real node its smoothing) as it is polled.