diff --git a/crates/lantern-app/src/application.rs b/crates/lantern-app/src/application.rs index b498b844..044d8742 100644 --- a/crates/lantern-app/src/application.rs +++ b/crates/lantern-app/src/application.rs @@ -1,6 +1,6 @@ -use std::{path::PathBuf, sync::Arc}; +use std::sync::Arc; -use lantern_domain::{DriveState, ProfileId, SessionId, SlaveId}; +use lantern_domain::{DriveState, ProfileId, SessionId}; use lantern_profile::ValidatedDeviceProfile; use crate::{ @@ -42,58 +42,7 @@ pub struct ApplicationState { write_guard_revision: u64, } -impl Default for ApplicationState { - fn default() -> Self { - Self { - active_profile: None, - registry: Arc::new(ProfileRegistry::default()), - session: SessionStateMachine::new(false), - connection: ConnectionWizardState::default(), - monitoring: ApplicationMonitoringState::default(), - parameters: ApplicationParameterState::default(), - faults: FaultTracker::default(), - backup_restore: BackupRestoreState::default(), - write_guard_revision: 0, - } - } -} - impl ApplicationState { - #[must_use] - pub fn with_registry(registry: Arc, process_writes_enabled: bool) -> Self { - Self::with_registry_and_suggestions(registry, process_writes_enabled, None, None) - } - - #[must_use] - pub fn with_registry_and_suggestions( - registry: Arc, - process_writes_enabled: bool, - suggested_device: Option, - suggested_slave: Option, - ) -> Self { - Self { - active_profile: None, - registry, - session: SessionStateMachine::new(process_writes_enabled), - connection: ConnectionWizardState::new(suggested_device, suggested_slave), - monitoring: ApplicationMonitoringState::default(), - parameters: ApplicationParameterState::default(), - faults: FaultTracker::default(), - backup_restore: BackupRestoreState::default(), - write_guard_revision: 0, - } - } - - #[must_use] - pub fn registry(&self) -> &Arc { - &self.registry - } - - #[must_use] - pub const fn session(&self) -> &SessionStateMachine { - &self.session - } - fn write_session_snapshot(&self) -> Option { let SessionState::Active(active) = self.session.state() else { return None; diff --git a/crates/lantern-app/src/application/state.rs b/crates/lantern-app/src/application/state.rs index c4482cc7..e8b9dbd9 100644 --- a/crates/lantern-app/src/application/state.rs +++ b/crates/lantern-app/src/application/state.rs @@ -1,13 +1,17 @@ -use std::sync::Arc; +use std::{path::PathBuf, sync::Arc}; -use lantern_domain::ParameterId; +use lantern_domain::{ParameterId, SlaveId}; use lantern_profile::ValidatedDeviceProfile; use crate::{ - CsvLoggingRuntimeStatus, MonitoringRuntimeSnapshot, ParameterDescriptorView, PreparedWritePlan, - ScopeSelection, StagedWriteIntent, default_dashboard_parameters, parameter_catalog, + BackupRestoreState, ConnectionWizardState, CsvLoggingRuntimeStatus, FaultTracker, + MonitoringRuntimeSnapshot, ParameterDescriptorView, PreparedWritePlan, ProfileRegistry, + ScopeSelection, SessionStateMachine, StagedWriteIntent, default_dashboard_parameters, + parameter_catalog, }; +use super::ApplicationState; + #[derive(Clone, Debug, Default)] pub(super) struct ApplicationMonitoringState { pub(super) dashboard_parameters: Vec, @@ -64,3 +68,56 @@ impl ApplicationParameterState { } } } + +impl Default for ApplicationState { + fn default() -> Self { + Self { + active_profile: None, + registry: Arc::new(ProfileRegistry::default()), + session: SessionStateMachine::new(false), + connection: ConnectionWizardState::default(), + monitoring: ApplicationMonitoringState::default(), + parameters: ApplicationParameterState::default(), + faults: FaultTracker::default(), + backup_restore: BackupRestoreState::default(), + write_guard_revision: 0, + } + } +} + +impl ApplicationState { + #[must_use] + pub fn with_registry(registry: Arc, process_writes_enabled: bool) -> Self { + Self::with_registry_and_suggestions(registry, process_writes_enabled, None, None) + } + + #[must_use] + pub fn with_registry_and_suggestions( + registry: Arc, + process_writes_enabled: bool, + suggested_device: Option, + suggested_slave: Option, + ) -> Self { + Self { + active_profile: None, + registry, + session: SessionStateMachine::new(process_writes_enabled), + connection: ConnectionWizardState::new(suggested_device, suggested_slave), + monitoring: ApplicationMonitoringState::default(), + parameters: ApplicationParameterState::default(), + faults: FaultTracker::default(), + backup_restore: BackupRestoreState::default(), + write_guard_revision: 0, + } + } + + #[must_use] + pub fn registry(&self) -> &Arc { + &self.registry + } + + #[must_use] + pub const fn session(&self) -> &SessionStateMachine { + &self.session + } +}