Skip to main content

ax_driver/
error.rs

1#[derive(Debug)]
2pub enum Error {
3    Driver(rdrive::error::DriverError),
4    Probe(rdrive::ProbeError),
5}
6
7pub type Result<T = ()> = core::result::Result<T, Error>;
8
9impl core::fmt::Display for Error {
10    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
11        match self {
12            Self::Driver(err) => write!(f, "driver init failed: {err}"),
13            Self::Probe(err) => write!(f, "driver probe failed: {err}"),
14        }
15    }
16}
17
18impl core::error::Error for Error {}
19
20impl From<rdrive::error::DriverError> for Error {
21    fn from(value: rdrive::error::DriverError) -> Self {
22        Self::Driver(value)
23    }
24}
25
26impl From<rdrive::ProbeError> for Error {
27    fn from(value: rdrive::ProbeError) -> Self {
28        Self::Probe(value)
29    }
30}