pub struct App {Show 43 fields
pub should_quit: bool,
pub active_tab: Tab,
pub selected_device: usize,
pub devices: Vec<DeviceState>,
pub scanning: bool,
pub status_messages: Vec<(String, Instant)>,
pub status_message_timeout: u64,
pub show_help: bool,
pub command_tx: Sender<Command>,
pub event_rx: Receiver<SensorEvent>,
pub thresholds: Thresholds,
pub alerts: Vec<Alert>,
pub alert_history: Vec<AlertRecord>,
pub show_alert_history: bool,
pub log_file: Option<PathBuf>,
pub logging_enabled: bool,
pub last_auto_refresh: Option<Instant>,
pub auto_refresh_interval: Duration,
pub history_scroll: usize,
pub history_filter: HistoryFilter,
pub spinner_frame: usize,
pub selected_setting: usize,
pub interval_options: Vec<u16>,
pub co2_alert_threshold: u16,
pub radon_alert_threshold: u16,
pub bell_enabled: bool,
pub device_filter: DeviceFilter,
pub pending_confirmation: Option<PendingAction>,
pub show_sidebar: bool,
pub show_fullscreen_chart: bool,
pub editing_alias: bool,
pub alias_input: String,
pub sticky_alerts: bool,
pub last_error: Option<String>,
pub show_error_details: bool,
pub show_comparison: bool,
pub comparison_device_index: Option<usize>,
pub sidebar_width: u16,
pub theme: Theme,
pub chart_metrics: u8,
pub smart_home_enabled: bool,
pub ble_range: BleRange,
pub syncing: bool,
}Expand description
Main application state for the TUI.
Fields§
§should_quit: boolWhether the application should exit.
active_tab: TabCurrently active UI tab.
selected_device: usizeIndex of the currently selected device.
devices: Vec<DeviceState>List of all known devices.
scanning: boolWhether a device scan is in progress.
status_messages: Vec<(String, Instant)>Queue of status messages with their creation time.
status_message_timeout: u64How long to show each status message (in seconds).
show_help: boolWhether to show the help overlay.
command_tx: Sender<Command>Channel for sending commands to the background worker.
event_rx: Receiver<SensorEvent>Channel for receiving events from the background worker.
thresholds: ThresholdsThreshold evaluator for CO2 levels.
alerts: Vec<Alert>Active alerts for devices.
alert_history: Vec<AlertRecord>History of all alerts (for viewing).
show_alert_history: boolWhether to show alert history overlay.
log_file: Option<PathBuf>Path to log file for data logging.
logging_enabled: boolWhether logging is enabled.
last_auto_refresh: Option<Instant>When the last auto-refresh was triggered.
auto_refresh_interval: DurationAuto-refresh interval (uses device interval or 60s default).
history_scroll: usizeScroll offset for history list in History tab.
history_filter: HistoryFilterTime range filter for history display.
spinner_frame: usizeSpinner animation frame counter.
selected_setting: usizeCurrently selected setting in the Settings tab.
interval_options: Vec<u16>Available interval options in seconds.
co2_alert_threshold: u16Custom CO2 alert threshold (ppm). Default is 1500 (Poor level).
radon_alert_threshold: u16Custom radon alert threshold (Bq/m³). Default is 300.
bell_enabled: boolWhether to ring terminal bell on alerts.
device_filter: DeviceFilterDevice list filter.
pending_confirmation: Option<PendingAction>Pending confirmation action.
Whether to show the device sidebar (can be hidden on narrow terminals).
show_fullscreen_chart: boolWhether to show full-screen chart view.
editing_alias: boolWhether currently editing device alias.
alias_input: StringCurrent alias input buffer.
sticky_alerts: boolWhether alerts are sticky (don’t auto-clear when condition improves).
last_error: Option<String>Last error message (full details).
show_error_details: boolWhether to show error details popup.
show_comparison: boolWhether comparison view is active.
comparison_device_index: Option<usize>Index of second device for comparison (first is selected_device).
Sidebar width (default 28, wide 40).
theme: ThemeCurrent UI theme.
chart_metrics: u8Which metrics to show on sparkline (bitmask: 1=primary, 2=temp, 4=humidity).
smart_home_enabled: boolWhether Smart Home integration mode is enabled.
ble_range: BleRangeBluetooth range setting.
syncing: boolWhether a history sync is in progress.
Implementations§
Source§impl App
impl App
Sourcepub const METRIC_PRIMARY: u8 = 0b001
pub const METRIC_PRIMARY: u8 = 0b001
Bitmask constant for primary metric (CO2/Radon/Radiation).
Sourcepub const METRIC_TEMP: u8 = 0b010
pub const METRIC_TEMP: u8 = 0b010
Bitmask constant for temperature metric.
Sourcepub const METRIC_HUMIDITY: u8 = 0b100
pub const METRIC_HUMIDITY: u8 = 0b100
Bitmask constant for humidity metric.
Sourcepub fn new(command_tx: Sender<Command>, event_rx: Receiver<SensorEvent>) -> Self
pub fn new(command_tx: Sender<Command>, event_rx: Receiver<SensorEvent>) -> Self
Create a new application with the given command and event channels.
Sourcepub fn toggle_ble_range(&mut self)
pub fn toggle_ble_range(&mut self)
Toggle Bluetooth range.
Sourcepub fn toggle_chart_metric(&mut self, metric: u8)
pub fn toggle_chart_metric(&mut self, metric: u8)
Toggle a metric on the chart.
Sourcepub fn chart_shows(&self, metric: u8) -> bool
pub fn chart_shows(&self, metric: u8) -> bool
Check if a metric is enabled on chart.
Sourcepub fn toggle_theme(&mut self)
pub fn toggle_theme(&mut self)
Toggle between light and dark theme.
Sourcepub fn toggle_smart_home(&mut self)
pub fn toggle_smart_home(&mut self)
Toggle Smart Home mode.
Sourcepub fn toggle_fullscreen_chart(&mut self)
pub fn toggle_fullscreen_chart(&mut self)
Toggle full-screen chart view.
Sourcepub fn should_quit(&self) -> bool
pub fn should_quit(&self) -> bool
Returns whether the application should quit.
Sourcepub fn push_status_message(&mut self, message: String)
pub fn push_status_message(&mut self, message: String)
Add a status message to the queue.
Sourcepub fn clean_expired_messages(&mut self)
pub fn clean_expired_messages(&mut self)
Remove expired status messages.
Sourcepub fn current_status_message(&self) -> Option<&str>
pub fn current_status_message(&self) -> Option<&str>
Get the current status message to display.
Sourcepub fn handle_sensor_event(&mut self, event: SensorEvent) -> Vec<Command>
pub fn handle_sensor_event(&mut self, event: SensorEvent) -> Vec<Command>
Handle an incoming sensor event and update state accordingly.
Returns a list of commands to send to the worker (for auto-connect, auto-sync, etc.).
Sourcepub fn selected_device(&self) -> Option<&DeviceState>
pub fn selected_device(&self) -> Option<&DeviceState>
Get a reference to the currently selected device, if any.
Sourcepub fn select_next_device(&mut self)
pub fn select_next_device(&mut self)
Select the next device in the list.
Sourcepub fn select_previous_device(&mut self)
pub fn select_previous_device(&mut self)
Select the previous device in the list.
Sourcepub fn scroll_history_up(&mut self)
pub fn scroll_history_up(&mut self)
Scroll history list up by one page.
Sourcepub fn scroll_history_down(&mut self)
pub fn scroll_history_down(&mut self)
Scroll history list down by one page.
Sourcepub fn reset_history_scroll(&mut self)
pub fn reset_history_scroll(&mut self)
Reset history scroll when device changes.
Sourcepub fn tick_spinner(&mut self)
pub fn tick_spinner(&mut self)
Advance the spinner animation frame.
Sourcepub fn spinner_char(&self) -> &'static str
pub fn spinner_char(&self) -> &'static str
Get the current spinner character.
Sourcepub fn set_history_filter(&mut self, filter: HistoryFilter)
pub fn set_history_filter(&mut self, filter: HistoryFilter)
Set history filter.
Sourcepub fn filtered_devices(&self) -> Vec<&DeviceState>
pub fn filtered_devices(&self) -> Vec<&DeviceState>
Get devices matching current filter.
Sourcepub fn cycle_device_filter(&mut self)
pub fn cycle_device_filter(&mut self)
Cycle device filter to next option.
Sourcepub fn select_next_setting(&mut self)
pub fn select_next_setting(&mut self)
Select the next setting in the Settings tab.
Sourcepub fn select_previous_setting(&mut self)
pub fn select_previous_setting(&mut self)
Select the previous setting in the Settings tab.
Sourcepub fn increase_co2_threshold(&mut self)
pub fn increase_co2_threshold(&mut self)
Increase CO2 threshold by 100 ppm.
Sourcepub fn decrease_co2_threshold(&mut self)
pub fn decrease_co2_threshold(&mut self)
Decrease CO2 threshold by 100 ppm.
Sourcepub fn increase_radon_threshold(&mut self)
pub fn increase_radon_threshold(&mut self)
Increase radon threshold by 50 Bq/m³.
Sourcepub fn decrease_radon_threshold(&mut self)
pub fn decrease_radon_threshold(&mut self)
Decrease radon threshold by 50 Bq/m³.
Sourcepub fn cycle_interval(&mut self) -> Option<(String, u16)>
pub fn cycle_interval(&mut self) -> Option<(String, u16)>
Cycle to next interval option.
Sourcepub fn check_thresholds(&mut self, device_id: &str, reading: &CurrentReading)
pub fn check_thresholds(&mut self, device_id: &str, reading: &CurrentReading)
Check if a reading exceeds thresholds and create an alert if needed.
Sourcepub fn dismiss_alert(&mut self, device_id: &str)
pub fn dismiss_alert(&mut self, device_id: &str)
Dismiss an alert for a device.
Sourcepub fn toggle_alert_history(&mut self)
pub fn toggle_alert_history(&mut self)
Toggle alert history view.
Sourcepub fn toggle_sticky_alerts(&mut self)
pub fn toggle_sticky_alerts(&mut self)
Toggle sticky alerts mode.
Sourcepub fn toggle_logging(&mut self)
pub fn toggle_logging(&mut self)
Toggle data logging on/off.
Sourcepub fn log_reading(&self, device_id: &str, reading: &CurrentReading)
pub fn log_reading(&self, device_id: &str, reading: &CurrentReading)
Log a reading to file.
Sourcepub fn export_history(&self) -> Option<String>
pub fn export_history(&self) -> Option<String>
Export visible history to CSV file.
Sourcepub fn check_auto_refresh(&mut self) -> Vec<String>
pub fn check_auto_refresh(&mut self) -> Vec<String>
Check if auto-refresh is due and return list of connected device IDs to refresh.
Sourcepub fn request_confirmation(&mut self, action: PendingAction)
pub fn request_confirmation(&mut self, action: PendingAction)
Request confirmation for an action.
Sourcepub fn confirm_action(&mut self) -> Option<Command>
pub fn confirm_action(&mut self) -> Option<Command>
Confirm the pending action.
Sourcepub fn cancel_confirmation(&mut self)
pub fn cancel_confirmation(&mut self)
Cancel the pending action.
Toggle sidebar visibility.
Toggle between normal and wide sidebar.
Sourcepub fn start_alias_edit(&mut self)
pub fn start_alias_edit(&mut self)
Start editing alias for selected device.
Sourcepub fn cancel_alias_edit(&mut self)
pub fn cancel_alias_edit(&mut self)
Cancel alias editing.
Sourcepub fn save_alias(&mut self)
pub fn save_alias(&mut self)
Save the alias.
Sourcepub fn alias_input_char(&mut self, c: char)
pub fn alias_input_char(&mut self, c: char)
Handle character input for alias editing.
Sourcepub fn alias_input_backspace(&mut self)
pub fn alias_input_backspace(&mut self)
Handle backspace for alias editing.
Sourcepub fn toggle_error_details(&mut self)
pub fn toggle_error_details(&mut self)
Toggle error details popup.
Sourcepub fn average_co2(&self) -> Option<u16>
pub fn average_co2(&self) -> Option<u16>
Get average CO2 across all connected devices with readings.
Sourcepub fn connected_count(&self) -> usize
pub fn connected_count(&self) -> usize
Get count of connected devices.
Sourcepub fn is_any_connecting(&self) -> bool
pub fn is_any_connecting(&self) -> bool
Check if any device is currently connecting.
Sourcepub fn is_syncing(&self) -> bool
pub fn is_syncing(&self) -> bool
Check if a history sync is in progress.
Sourcepub fn toggle_comparison(&mut self)
pub fn toggle_comparison(&mut self)
Toggle comparison view.
Sourcepub fn cycle_comparison_device(&mut self, forward: bool)
pub fn cycle_comparison_device(&mut self, forward: bool)
Cycle the comparison device.
Sourcepub fn comparison_device(&self) -> Option<&DeviceState>
pub fn comparison_device(&self) -> Option<&DeviceState>
Get the comparison device.
Auto Trait Implementations§
impl Freeze for App
impl RefUnwindSafe for App
impl Send for App
impl Sync for App
impl Unpin for App
impl UnwindSafe for App
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more