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