Skip to content

Commit 88b1e3a

Browse files
committed
handle case when battery is unavailable
1 parent 0a0e92e commit 88b1e3a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/dmi.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub struct DMI {
3636
baseboard: Baseboard,
3737
chassis: Chassis,
3838
memory: Memory,
39-
battery: Battery,
39+
battery: Option<Battery>,
4040
pub focused_section: FocusedSection,
4141
}
4242

@@ -199,7 +199,7 @@ impl DMI {
199199
baseboard: baseboard.unwrap(),
200200
chassis: chassis.unwrap(),
201201
memory: memory.unwrap(),
202-
battery: battery.unwrap(),
202+
battery,
203203
focused_section: FocusedSection::Firmware,
204204
})
205205
}
@@ -344,7 +344,9 @@ impl DMI {
344344
self.memory.render(frame, section_block);
345345
}
346346
FocusedSection::Battery => {
347-
self.battery.render(frame, section_block);
347+
if let Some(battery) = &self.battery {
348+
battery.render(frame, section_block);
349+
}
348350
}
349351
}
350352
}

0 commit comments

Comments
 (0)