Explicitly return DriversAlreadyTakenError
diff --git a/src/drivers.rs b/src/drivers.rs
index 8d8e8ab..185f6ea 100644
--- a/src/drivers.rs
+++ b/src/drivers.rs
@@ -5,7 +5,6 @@
use crate::leds::LedsDriverFactory;
use crate::result::OtherError;
use crate::result::TockError;
-use crate::result::TockResult;
use crate::rng::RngDriver;
use crate::sensors::ninedof::NinedofDriver;
use crate::sensors::AmbientLightSensor;
@@ -37,12 +36,12 @@
}
/// Retrieve [Drivers] struct. Returns struct only once.
-pub fn retrieve_drivers() -> TockResult<Drivers> {
+pub fn retrieve_drivers() -> Result<Drivers, DriversAlreadyTakenError> {
static mut DRIVER_TAKEN: bool = false;
unsafe {
if DRIVER_TAKEN {
- Err(TockError::Other(OtherError::DriverAlreadyTaken))
+ Err(DriversAlreadyTakenError)
} else {
DRIVER_TAKEN = true;
Ok(retrieve_drivers_unsafe())
@@ -79,3 +78,11 @@
humidity_sensor: HumiditySensor,
ninedof: NinedofDriver,
};
+
+pub struct DriversAlreadyTakenError;
+
+impl From<DriversAlreadyTakenError> for TockError {
+ fn from(_: DriversAlreadyTakenError) -> Self {
+ TockError::Other(OtherError::DriversAlreadyTaken)
+ }
+}
diff --git a/src/result.rs b/src/result.rs
index 74b4786..84af6bf 100644
--- a/src/result.rs
+++ b/src/result.rs
@@ -50,8 +50,8 @@
GpioDriverInvalidState,
TimerDriverDurationOutOfRange,
TimerDriverErroneousClockFrequency,
- DriverAlreadyTaken,
- OutOfRangeError,
+ DriversAlreadyTaken,
+ OutOfRange,
}
impl From<OtherError> for TockError {
@@ -63,7 +63,7 @@
pub struct OutOfRangeError;
impl From<OutOfRangeError> for TockError {
- fn from(_other: OutOfRangeError) -> Self {
- TockError::Other(OtherError::OutOfRangeError)
+ fn from(_: OutOfRangeError) -> Self {
+ TockError::Other(OtherError::OutOfRange)
}
}