diff --git a/backend/src/domain/health.rs b/backend/src/domain/health.rs index 897d83e..83891dc 100644 --- a/backend/src/domain/health.rs +++ b/backend/src/domain/health.rs @@ -106,12 +106,12 @@ impl HealthStatus { #[must_use] pub fn record_error(self) -> Self { match self { - Self::Healthy => Self::Degraded { consecutive_errors: 1 }, - Self::Degraded { consecutive_errors } => { - Self::Degraded { - consecutive_errors: consecutive_errors + 1, - } - } + Self::Healthy => Self::Degraded { + consecutive_errors: 1, + }, + Self::Degraded { consecutive_errors } => Self::Degraded { + consecutive_errors: consecutive_errors + 1, + }, Self::Unhealthy { reason } => Self::Unhealthy { reason }, } } @@ -161,7 +161,12 @@ mod tests { assert!(!status.is_healthy()); assert!(status.is_degraded()); assert!(!status.is_unhealthy()); - assert_eq!(status, HealthStatus::Degraded { consecutive_errors: 3 }); + assert_eq!( + status, + HealthStatus::Degraded { + consecutive_errors: 3 + } + ); } #[test] @@ -183,7 +188,12 @@ mod tests { let status = HealthStatus::healthy(); let status = status.record_error(); assert!(status.is_degraded()); - assert_eq!(status, HealthStatus::Degraded { consecutive_errors: 1 }); + assert_eq!( + status, + HealthStatus::Degraded { + consecutive_errors: 1 + } + ); } #[test] @@ -191,7 +201,12 @@ mod tests { let status = HealthStatus::degraded(2); let status = status.record_error(); assert!(status.is_degraded()); - assert_eq!(status, HealthStatus::Degraded { consecutive_errors: 3 }); + assert_eq!( + status, + HealthStatus::Degraded { + consecutive_errors: 3 + } + ); } #[test] @@ -274,15 +289,30 @@ mod tests { // Record first error -> Degraded with 1 error let status = status.record_error(); assert!(status.is_degraded()); - assert_eq!(status, HealthStatus::Degraded { consecutive_errors: 1 }); + assert_eq!( + status, + HealthStatus::Degraded { + consecutive_errors: 1 + } + ); // Record second error -> Degraded with 2 errors let status = status.record_error(); - assert_eq!(status, HealthStatus::Degraded { consecutive_errors: 2 }); + assert_eq!( + status, + HealthStatus::Degraded { + consecutive_errors: 2 + } + ); // Record third error -> Degraded with 3 errors let status = status.record_error(); - assert_eq!(status, HealthStatus::Degraded { consecutive_errors: 3 }); + assert_eq!( + status, + HealthStatus::Degraded { + consecutive_errors: 3 + } + ); // Mark unhealthy -> Unhealthy let status = status.mark_unhealthy("Too many consecutive errors"); diff --git a/backend/src/domain/mod.rs b/backend/src/domain/mod.rs index b8505ff..6f65b65 100644 --- a/backend/src/domain/mod.rs +++ b/backend/src/domain/mod.rs @@ -35,6 +35,6 @@ //! - Type design: `specs/001-modbus-relay-control/types-design.md` //! - Domain specification: `specs/001-modbus-relay-control/spec.md` -pub mod relay; -pub mod modbus; pub mod health; +pub mod modbus; +pub mod relay; diff --git a/backend/src/domain/relay/controler.rs b/backend/src/domain/relay/controller.rs similarity index 100% rename from backend/src/domain/relay/controler.rs rename to backend/src/domain/relay/controller.rs diff --git a/backend/src/domain/relay/entity.rs b/backend/src/domain/relay/entity.rs index 00d52e0..265cfe8 100644 --- a/backend/src/domain/relay/entity.rs +++ b/backend/src/domain/relay/entity.rs @@ -54,7 +54,6 @@ impl Relay { pub fn label(&self) -> Option { self.label.clone() } - } #[cfg(test)] diff --git a/backend/src/domain/relay/mod.rs b/backend/src/domain/relay/mod.rs index 26748e6..84ab6a3 100644 --- a/backend/src/domain/relay/mod.rs +++ b/backend/src/domain/relay/mod.rs @@ -3,11 +3,11 @@ //! This module contains the core domain logic for relay control and management, //! including relay types, repository abstractions, and business rules. +/// Controller error types for relay operations. +pub mod controller; +/// Relay entity representing the relay aggregate. +pub mod entity; /// Repository trait and error types for relay persistence. pub mod repository; /// Domain types for relay identification and control. pub mod types; -/// Controller error types for relay operations. -pub mod controler; -/// Relay entity representing the relay aggregate. -pub mod entity; diff --git a/backend/src/domain/relay/types/mod.rs b/backend/src/domain/relay/types/mod.rs index e7ac867..573faa9 100644 --- a/backend/src/domain/relay/types/mod.rs +++ b/backend/src/domain/relay/types/mod.rs @@ -1,7 +1,7 @@ mod relayid; -mod relaystate; mod relaylabel; +mod relaystate; pub use relayid::RelayId; -pub use relaystate::RelayState; pub use relaylabel::RelayLabel; +pub use relaystate::RelayState; diff --git a/backend/src/domain/relay/types/relayid.rs b/backend/src/domain/relay/types/relayid.rs index 9479543..d13fca6 100644 --- a/backend/src/domain/relay/types/relayid.rs +++ b/backend/src/domain/relay/types/relayid.rs @@ -1,4 +1,4 @@ -use crate::domain::relay::controler::ControllerError; +use crate::domain::relay::controller::ControllerError; /// Unique identifier for a relay in the system. /// @@ -33,7 +33,6 @@ impl RelayId { pub const fn as_u8(&self) -> u8 { self.0 } - } impl std::fmt::Display for RelayId { diff --git a/backend/src/domain/relay/types/relaylabel.rs b/backend/src/domain/relay/types/relaylabel.rs index 6ee06d9..425ad3e 100644 --- a/backend/src/domain/relay/types/relaylabel.rs +++ b/backend/src/domain/relay/types/relaylabel.rs @@ -1,5 +1,3 @@ -use std::fmt::Display; - use thiserror::Error; /// Human-readable label for a relay. @@ -15,7 +13,7 @@ pub enum RelayLabelError { #[error("Label cannot be empty")] Empty, #[error("Label exceeds maximum length of 50 characters: {0}")] - TooLong(usize) + TooLong(usize), } impl RelayLabel {