Skip to main content

pacsea/state/
mod.rs

1//! Modularized state module.
2//!
3//! This splits the original monolithic `state.rs` into smaller files while
4//! preserving the public API under `crate::state::*` via re-exports.
5
6pub mod app_state;
7pub mod main_vertical_pane;
8pub mod modal;
9pub mod types;
10
11// Public re-exports to keep existing paths working
12pub use app_state::AppState;
13pub use main_vertical_pane::{
14    DEFAULT_MAIN_PANE_ORDER, MainVerticalPane, VerticalLayoutLimits, format_main_pane_order,
15    parse_main_pane_order,
16};
17pub use modal::{Modal, PreflightAction, PreflightTab, SshSetupStep};
18pub use types::{
19    ArchStatusColor, Focus, InstalledPackagesMode, NewsItem, PackageDetails, PackageItem,
20    PkgbuildCheckRequest, PkgbuildCheckResponse, QueryInput, RightPaneFocus, SearchResults,
21    SecureString, SortMode, Source,
22};
23
24#[cfg(test)]
25static TEST_MUTEX: std::sync::OnceLock<std::sync::Mutex<()>> = std::sync::OnceLock::new();
26
27#[cfg(test)]
28/// What: Provide a shared mutex so state tests can run without stepping on
29/// shared environment variables.
30///
31/// - Input: None; invoked by tests prior to mutating global state.
32/// - Output: Reference to a lazily-initialized `Mutex<()>` used for guarding
33///   shared setup/teardown.
34/// - Details: Ensures tests that modify `HOME` or other global process state
35///   run serially and remain deterministic across platforms.
36pub(crate) fn test_mutex() -> &'static std::sync::Mutex<()> {
37    TEST_MUTEX.get_or_init(|| std::sync::Mutex::new(()))
38}