diff --git a/crates/lantern-app/src/application.rs b/crates/lantern-app/src/application.rs index a6d2eb34..e5e98bb9 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 lantern_domain::{DriveState, ParameterId, ProfileId, SessionId, SlaveId}; +use lantern_domain::{DriveState, ProfileId, SessionId, SlaveId}; use lantern_profile::ValidatedDeviceProfile; use thiserror::Error; @@ -8,85 +8,28 @@ use crate::{ AuditHealth, Authorization, BackupCaptureRequest, BackupRestoreAction, BackupRestoreEffect, BackupRestoreState, BusError, ConnectionAction, ConnectionAttemptKind, ConnectionEffect, ConnectionFailure, ConnectionStep, ConnectionWizardState, Connectivity, CsvLoggingFaultSummary, - CsvLoggingRuntimeStatus, CsvLoggingStateView, FaultAction, FaultEffect, FaultTracker, - MAX_PARAMETER_BROWSER_VISIBLE, MonitoringAction, MonitoringEffect, MonitoringRuntimeSnapshot, - MonitoringView, OperationState, ParameterAction, ParameterBrowserView, ParameterDescriptorView, - ParameterIntentContext, ParameterWritePresentation, PreparedWritePlan, ProfileRegistry, - RestoreConfirmation, ScopeSelection, SerialConnectError, SessionEffect, SessionFault, - SessionInput, SessionState, SessionStateMachine, StagedWriteIntent, WriteConfirmation, - WriteConfirmationModel, WriteEffect, WriteSessionSnapshot, default_dashboard_parameters, - parameter_catalog, prepare_parameter_intent, project_monitoring_view, + CsvLoggingStateView, FaultAction, FaultEffect, FaultTracker, MAX_PARAMETER_BROWSER_VISIBLE, + MonitoringAction, MonitoringEffect, MonitoringView, OperationState, ParameterAction, + ParameterBrowserView, ParameterIntentContext, ParameterWritePresentation, ProfileRegistry, + RestoreConfirmation, SerialConnectError, SessionEffect, SessionFault, SessionInput, + SessionState, SessionStateMachine, WriteConfirmation, WriteConfirmationModel, WriteEffect, + WriteSessionSnapshot, prepare_parameter_intent, project_monitoring_view, project_parameter_browser_view, }; mod connection; mod faults; mod monitoring; +mod state; mod view; +use state::{ApplicationMonitoringState, ApplicationParameterState}; use view::port_label; pub use view::{ ApplicationView, AuditHealthView, AuthorizationView, OperationView, SessionPhaseView, SessionView, }; -#[derive(Clone, Debug, Default)] -struct ApplicationMonitoringState { - dashboard_parameters: Vec, - scope: ScopeSelection, - snapshot: Option, - csv_parameters: Vec, - csv_status: CsvLoggingRuntimeStatus, - next_logging_id: u128, - error: Option, -} - -impl ApplicationMonitoringState { - fn for_profile(profile: &ValidatedDeviceProfile) -> Self { - Self { - dashboard_parameters: default_dashboard_parameters(profile), - scope: ScopeSelection::default(), - snapshot: None, - csv_parameters: Vec::new(), - csv_status: CsvLoggingRuntimeStatus::default(), - next_logging_id: 1, - error: None, - } - } -} - -#[derive(Clone, Debug)] -struct ApplicationParameterState { - catalog: Arc<[ParameterDescriptorView]>, - visible: Vec, - staged_intent: Option, - prepared_write: Option, - write_status: Option, - error: Option, -} - -impl Default for ApplicationParameterState { - fn default() -> Self { - Self { - catalog: Vec::::new().into(), - visible: Vec::new(), - staged_intent: None, - prepared_write: None, - write_status: None, - error: None, - } - } -} - -impl ApplicationParameterState { - fn for_profile(profile: &ValidatedDeviceProfile) -> Self { - Self { - catalog: parameter_catalog(profile), - ..Self::default() - } - } -} - #[derive(Clone, Debug)] pub struct ApplicationState { active_profile: Option, diff --git a/crates/lantern-app/src/application/state.rs b/crates/lantern-app/src/application/state.rs new file mode 100644 index 00000000..c4482cc7 --- /dev/null +++ b/crates/lantern-app/src/application/state.rs @@ -0,0 +1,66 @@ +use std::sync::Arc; + +use lantern_domain::ParameterId; +use lantern_profile::ValidatedDeviceProfile; + +use crate::{ + CsvLoggingRuntimeStatus, MonitoringRuntimeSnapshot, ParameterDescriptorView, PreparedWritePlan, + ScopeSelection, StagedWriteIntent, default_dashboard_parameters, parameter_catalog, +}; + +#[derive(Clone, Debug, Default)] +pub(super) struct ApplicationMonitoringState { + pub(super) dashboard_parameters: Vec, + pub(super) scope: ScopeSelection, + pub(super) snapshot: Option, + pub(super) csv_parameters: Vec, + pub(super) csv_status: CsvLoggingRuntimeStatus, + pub(super) next_logging_id: u128, + pub(super) error: Option, +} + +impl ApplicationMonitoringState { + pub(super) fn for_profile(profile: &ValidatedDeviceProfile) -> Self { + Self { + dashboard_parameters: default_dashboard_parameters(profile), + scope: ScopeSelection::default(), + snapshot: None, + csv_parameters: Vec::new(), + csv_status: CsvLoggingRuntimeStatus::default(), + next_logging_id: 1, + error: None, + } + } +} + +#[derive(Clone, Debug)] +pub(super) struct ApplicationParameterState { + pub(super) catalog: Arc<[ParameterDescriptorView]>, + pub(super) visible: Vec, + pub(super) staged_intent: Option, + pub(super) prepared_write: Option, + pub(super) write_status: Option, + pub(super) error: Option, +} + +impl Default for ApplicationParameterState { + fn default() -> Self { + Self { + catalog: Vec::::new().into(), + visible: Vec::new(), + staged_intent: None, + prepared_write: None, + write_status: None, + error: None, + } + } +} + +impl ApplicationParameterState { + pub(super) fn for_profile(profile: &ValidatedDeviceProfile) -> Self { + Self { + catalog: parameter_catalog(profile), + ..Self::default() + } + } +}