Move relay drivers from common to controller

This commit is contained in:
Tobias Reisinger 2024-05-05 23:46:49 +02:00
commit 228b366320
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
8 changed files with 132 additions and 270 deletions

View file

@ -6,9 +6,6 @@ use actix::MailboxError;
use actix_web::http::StatusCode;
use actix_web::HttpResponse;
use config::ConfigError;
use rppal::gpio;
use rppal_mcp23s17::Mcp23s17Error;
use rppal_pfd::PiFaceDigitalError;
use serde::ser::SerializeStruct;
use serde::{Serialize, Serializer};
@ -99,25 +96,6 @@ impl From<ConfigError> for EmgauwaError {
}
}
impl From<gpio::Error> for EmgauwaError {
fn from(value: gpio::Error) -> Self {
Self::Hardware(value.to_string())
}
}
impl From<PiFaceDigitalError> for EmgauwaError {
fn from(value: PiFaceDigitalError) -> Self {
match value {
PiFaceDigitalError::Mcp23s17Error { source } => match source {
Mcp23s17Error::SpiError { source } => Self::Hardware(source.to_string()),
_ => Self::Hardware(source.to_string()),
},
PiFaceDigitalError::GpioError { source } => Self::Hardware(source.to_string()),
_ => Self::Hardware(value.to_string()),
}
}
}
impl From<&EmgauwaError> for HttpResponse {
fn from(err: &EmgauwaError) -> Self {
HttpResponse::build(err.get_code()).json(err)