Add specific ChecksumError variant to BmsProtocolError
This commit is contained in:
@@ -29,6 +29,8 @@ pub trait BmsWriteable {
|
||||
pub enum BmsProtocolError {
|
||||
#[error("i2c communication failed")]
|
||||
I2cCommunicationError,
|
||||
#[error("checksum error in received data")]
|
||||
ChecksumError,
|
||||
}
|
||||
|
||||
impl<E> From<E> for BmsProtocolError
|
||||
@@ -41,8 +43,11 @@ where
|
||||
}
|
||||
|
||||
impl From<crate::types::U26Error> for BmsProtocolError {
|
||||
fn from(_error: crate::types::U26Error) -> Self {
|
||||
Self::I2cCommunicationError
|
||||
fn from(error: crate::types::U26Error) -> Self {
|
||||
match error {
|
||||
crate::types::U26Error::ChecksumError => Self::ChecksumError,
|
||||
_ => Self::I2cCommunicationError,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user