Skip to main content

AS5600_Driver/
error.rs

1use core::fmt;
2
3/// Custom error type for the AS5600 driver.
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub enum AS56Error<E> {
6    /// Error from the underlying I2C communication.
7    I2c(E),
8}
9
10impl<E: fmt::Debug> fmt::Display for AS56Error<E> {
11    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
12        match self {
13            AS56Error::I2c(e) => write!(f, "I2C error: {:?}", e),
14        }
15    }
16}
17
18#[cfg(feature = "std")]
19extern crate std;
20
21#[cfg(feature = "std")]
22impl<E: fmt::Debug> std::error::Error for AS56Error<E> {}