Check and pass error if charge limit not in 20-100 range

Closes #144
This commit is contained in:
Luke D. Jones
2021-10-27 22:59:04 +13:00
parent 3f0df82f2d
commit 7bc6c83a04
7 changed files with 16 additions and 11 deletions

View File

@@ -22,6 +22,7 @@ pub enum RogError {
Modprobe(String),
Io(std::io::Error),
Zbus(zbus::Error),
ChargeLimit(u8),
}
impl fmt::Display for RogError {
@@ -46,6 +47,7 @@ impl fmt::Display for RogError {
RogError::Modprobe(detail) => write!(f, "Modprobe error: {}", detail),
RogError::Io(detail) => write!(f, "std::io error: {}", detail),
RogError::Zbus(detail) => write!(f, "Zbus error: {}", detail),
RogError::ChargeLimit(value) => write!(f, "Invalid charging limit, not in range 20-100%: {}", value),
}
}
}