App

Struct App 

Source
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: bool

Whether the application should exit.

§active_tab: Tab

Currently active UI tab.

§selected_device: usize

Index of the currently selected device.

§devices: Vec<DeviceState>

List of all known devices.

§scanning: bool

Whether a device scan is in progress.

§status_messages: Vec<(String, Instant)>

Queue of status messages with their creation time.

§status_message_timeout: u64

How long to show each status message (in seconds).

§show_help: bool

Whether 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: Thresholds

Threshold evaluator for CO2 levels.

§alerts: Vec<Alert>

Active alerts for devices.

§alert_history: Vec<AlertRecord>

History of all alerts (for viewing).

§show_alert_history: bool

Whether to show alert history overlay.

§log_file: Option<PathBuf>

Path to log file for data logging.

§logging_enabled: bool

Whether logging is enabled.

§last_auto_refresh: Option<Instant>

When the last auto-refresh was triggered.

§auto_refresh_interval: Duration

Auto-refresh interval (uses device interval or 60s default).

§history_scroll: usize

Scroll offset for history list in History tab.

§history_filter: HistoryFilter

Time range filter for history display.

§spinner_frame: usize

Spinner animation frame counter.

§selected_setting: usize

Currently selected setting in the Settings tab.

§interval_options: Vec<u16>

Available interval options in seconds.

§co2_alert_threshold: u16

Custom CO2 alert threshold (ppm). Default is 1500 (Poor level).

§radon_alert_threshold: u16

Custom radon alert threshold (Bq/m³). Default is 300.

§bell_enabled: bool

Whether to ring terminal bell on alerts.

§device_filter: DeviceFilter

Device list filter.

§pending_confirmation: Option<PendingAction>

Pending confirmation action.

§show_sidebar: bool

Whether to show the device sidebar (can be hidden on narrow terminals).

§show_fullscreen_chart: bool

Whether to show full-screen chart view.

§editing_alias: bool

Whether currently editing device alias.

§alias_input: String

Current alias input buffer.

§sticky_alerts: bool

Whether alerts are sticky (don’t auto-clear when condition improves).

§last_error: Option<String>

Last error message (full details).

§show_error_details: bool

Whether to show error details popup.

§show_comparison: bool

Whether comparison view is active.

§comparison_device_index: Option<usize>

Index of second device for comparison (first is selected_device).

§sidebar_width: u16

Sidebar width (default 28, wide 40).

§theme: Theme

Current UI theme.

§chart_metrics: u8

Which metrics to show on sparkline (bitmask: 1=primary, 2=temp, 4=humidity).

§smart_home_enabled: bool

Whether Smart Home integration mode is enabled.

§ble_range: BleRange

Bluetooth range setting.

§syncing: bool

Whether a history sync is in progress.

Implementations§

Source§

impl App

Source

pub const METRIC_PRIMARY: u8 = 0b001

Bitmask constant for primary metric (CO2/Radon/Radiation).

Source

pub const METRIC_TEMP: u8 = 0b010

Bitmask constant for temperature metric.

Source

pub const METRIC_HUMIDITY: u8 = 0b100

Bitmask constant for humidity metric.

Source

pub fn new(command_tx: Sender<Command>, event_rx: Receiver<SensorEvent>) -> Self

Create a new application with the given command and event channels.

Source

pub fn toggle_ble_range(&mut self)

Toggle Bluetooth range.

Source

pub fn toggle_chart_metric(&mut self, metric: u8)

Toggle a metric on the chart.

Source

pub fn chart_shows(&self, metric: u8) -> bool

Check if a metric is enabled on chart.

Source

pub fn toggle_theme(&mut self)

Toggle between light and dark theme.

Source

pub fn app_theme(&self) -> AppTheme

Get the current AppTheme based on the theme setting.

Source

pub fn toggle_smart_home(&mut self)

Toggle Smart Home mode.

Source

pub fn toggle_fullscreen_chart(&mut self)

Toggle full-screen chart view.

Source

pub fn should_quit(&self) -> bool

Returns whether the application should quit.

Source

pub fn push_status_message(&mut self, message: String)

Add a status message to the queue.

Source

pub fn clean_expired_messages(&mut self)

Remove expired status messages.

Source

pub fn current_status_message(&self) -> Option<&str>

Get the current status message to display.

Source

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.).

Source

pub fn selected_device(&self) -> Option<&DeviceState>

Get a reference to the currently selected device, if any.

Source

pub fn select_next_device(&mut self)

Select the next device in the list.

Source

pub fn select_previous_device(&mut self)

Select the previous device in the list.

Source

pub fn scroll_history_up(&mut self)

Scroll history list up by one page.

Source

pub fn scroll_history_down(&mut self)

Scroll history list down by one page.

Source

pub fn reset_history_scroll(&mut self)

Reset history scroll when device changes.

Source

pub fn tick_spinner(&mut self)

Advance the spinner animation frame.

Source

pub fn spinner_char(&self) -> &'static str

Get the current spinner character.

Source

pub fn set_history_filter(&mut self, filter: HistoryFilter)

Set history filter.

Source

pub fn filtered_devices(&self) -> Vec<&DeviceState>

Get devices matching current filter.

Source

pub fn cycle_device_filter(&mut self)

Cycle device filter to next option.

Source

pub fn select_next_setting(&mut self)

Select the next setting in the Settings tab.

Source

pub fn select_previous_setting(&mut self)

Select the previous setting in the Settings tab.

Source

pub fn increase_co2_threshold(&mut self)

Increase CO2 threshold by 100 ppm.

Source

pub fn decrease_co2_threshold(&mut self)

Decrease CO2 threshold by 100 ppm.

Source

pub fn increase_radon_threshold(&mut self)

Increase radon threshold by 50 Bq/m³.

Source

pub fn decrease_radon_threshold(&mut self)

Decrease radon threshold by 50 Bq/m³.

Source

pub fn cycle_interval(&mut self) -> Option<(String, u16)>

Cycle to next interval option.

Source

pub fn check_thresholds(&mut self, device_id: &str, reading: &CurrentReading)

Check if a reading exceeds thresholds and create an alert if needed.

Source

pub fn dismiss_alert(&mut self, device_id: &str)

Dismiss an alert for a device.

Source

pub fn toggle_alert_history(&mut self)

Toggle alert history view.

Source

pub fn toggle_sticky_alerts(&mut self)

Toggle sticky alerts mode.

Source

pub fn toggle_logging(&mut self)

Toggle data logging on/off.

Source

pub fn log_reading(&self, device_id: &str, reading: &CurrentReading)

Log a reading to file.

Source

pub fn export_history(&self) -> Option<String>

Export visible history to CSV file.

Source

pub fn check_auto_refresh(&mut self) -> Vec<String>

Check if auto-refresh is due and return list of connected device IDs to refresh.

Source

pub fn request_confirmation(&mut self, action: PendingAction)

Request confirmation for an action.

Source

pub fn confirm_action(&mut self) -> Option<Command>

Confirm the pending action.

Source

pub fn cancel_confirmation(&mut self)

Cancel the pending action.

Source

pub fn toggle_sidebar(&mut self)

Toggle sidebar visibility.

Source

pub fn toggle_sidebar_width(&mut self)

Toggle between normal and wide sidebar.

Source

pub fn start_alias_edit(&mut self)

Start editing alias for selected device.

Source

pub fn cancel_alias_edit(&mut self)

Cancel alias editing.

Source

pub fn save_alias(&mut self)

Save the alias.

Source

pub fn alias_input_char(&mut self, c: char)

Handle character input for alias editing.

Source

pub fn alias_input_backspace(&mut self)

Handle backspace for alias editing.

Source

pub fn set_error(&mut self, error: String)

Store an error for later display.

Source

pub fn toggle_error_details(&mut self)

Toggle error details popup.

Source

pub fn average_co2(&self) -> Option<u16>

Get average CO2 across all connected devices with readings.

Source

pub fn connected_count(&self) -> usize

Get count of connected devices.

Source

pub fn is_any_connecting(&self) -> bool

Check if any device is currently connecting.

Source

pub fn is_syncing(&self) -> bool

Check if a history sync is in progress.

Source

pub fn toggle_comparison(&mut self)

Toggle comparison view.

Source

pub fn cycle_comparison_device(&mut self, forward: bool)

Cycle the comparison device.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more