From 8326525b45cacc6030870bb41212bab1448598e7 Mon Sep 17 00:00:00 2001 From: Markus Kasten Date: Fri, 5 Apr 2024 21:01:55 +0200 Subject: [PATCH] Rename `PinError::bus_error` to `driver_error` and add getter --- src/pin.rs | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/pin.rs b/src/pin.rs index 0800754..879584b 100644 --- a/src/pin.rs +++ b/src/pin.rs @@ -41,23 +41,33 @@ where } } +/// Error type for [`Pin`] which implements [`embedded_hal::digital::Error`]. #[derive(Debug)] -pub struct PinError { - pub bus_error: BE, +pub struct PinError { + driver_error: PDE, } -impl hal_digital::Error for PinError +impl PinError { + /// The upstream port driver error that occurred + pub fn driver_error(&self) -> &PDE { + &self.driver_error + } +} + +impl hal_digital::Error for PinError where - BE: core::fmt::Debug, + PDE: core::fmt::Debug, { fn kind(&self) -> hal_digital::ErrorKind { hal_digital::ErrorKind::Other } } -impl From for PinError { - fn from(value: BE) -> Self { - Self { bus_error: value } +impl From for PinError { + fn from(value: PDE) -> Self { + Self { + driver_error: value, + } } }