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
pub struct Component {
pub temperature: f32,
pub max: f32,
pub critical: Option<f32>,
pub label: String,
}
impl Component {
pub fn new(label: String, max: Option<f32>, critical: Option<f32>) -> Component {
Component {
temperature: 0f32,
label: label,
max: max.unwrap_or(0.0),
critical: critical,
}
}
}
pub fn update_component(comp: &mut Component, temperature: f32) {
comp.temperature = temperature;
if comp.temperature > comp.max {
comp.max = comp.temperature;
}
}