Skip to content

Commit

Permalink
Rename PinError::bus_error to driver_error and add getter
Browse files Browse the repository at this point in the history
  • Loading branch information
markus-k authored and Rahix committed Apr 6, 2024
1 parent 051a29f commit 8326525
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,33 @@ where
}
}

/// Error type for [`Pin`] which implements [`embedded_hal::digital::Error`].
#[derive(Debug)]
pub struct PinError<BE> {
pub bus_error: BE,
pub struct PinError<PDE> {
driver_error: PDE,
}

impl<BE> hal_digital::Error for PinError<BE>
impl<PDE> PinError<PDE> {
/// The upstream port driver error that occurred
pub fn driver_error(&self) -> &PDE {
&self.driver_error
}
}

impl<PDE> hal_digital::Error for PinError<PDE>
where
BE: core::fmt::Debug,
PDE: core::fmt::Debug,
{
fn kind(&self) -> hal_digital::ErrorKind {
hal_digital::ErrorKind::Other
}
}

impl<BE> From<BE> for PinError<BE> {
fn from(value: BE) -> Self {
Self { bus_error: value }
impl<PDE> From<PDE> for PinError<PDE> {
fn from(value: PDE) -> Self {
Self {
driver_error: value,
}
}
}

Expand Down

0 comments on commit 8326525

Please sign in to comment.