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 modal;
8pub mod types;
9
10// Public re-exports to keep existing paths working
11pub use app_state::AppState;
12pub use modal::{Modal, PreflightAction, PreflightTab};
13pub use types::{
14    ArchStatusColor, Focus, InstalledPackagesMode, NewsItem, PackageDetails, PackageItem,
15    QueryInput, RightPaneFocus, SearchResults, SortMode, Source,
16};
17
18#[cfg(test)]
19static TEST_MUTEX: std::sync::OnceLock<std::sync::Mutex<()>> = std::sync::OnceLock::new();
20
21#[cfg(test)]
22/// What: Provide a shared mutex so state tests can run without stepping on
23/// shared environment variables.
24///
25/// - Input: None; invoked by tests prior to mutating global state.
26/// - Output: Reference to a lazily-initialized `Mutex<()>` used for guarding
27///   shared setup/teardown.
28/// - Details: Ensures tests that modify `HOME` or other global process state
29///   run serially and remain deterministic across platforms.
30pub(crate) fn test_mutex() -> &'static std::sync::Mutex<()> {
31    TEST_MUTEX.get_or_init(|| std::sync::Mutex::new(()))
32}