use embedded_hal as hal;
use hal::blocking::i2c::{Read, Write};
use sensirion_i2c::i2c;
#[derive(Debug)]
pub enum SelfTestError {
Voc,
Nox,
All,
Undefined,
}
#[derive(Debug)]
pub enum Error<E> {
I2c(E),
Crc,
SelfTest(SelfTestError),
}
impl<E, I2cWrite, I2cRead> From<i2c::Error<I2cWrite, I2cRead>> for Error<E>
where
I2cWrite: Write<Error = E>,
I2cRead: Read<Error = E>,
{
fn from(err: i2c::Error<I2cWrite, I2cRead>) -> Self {
match err {
i2c::Error::Crc => Error::Crc,
i2c::Error::I2cWrite(e) => Error::I2c(e),
i2c::Error::I2cRead(e) => Error::I2c(e),
}
}
}