zoi-core 1.25.3

Advanced Package Manager & Environment Orchestrator
Documentation
use std::sync::{OnceLock, RwLock};

/// Returns the global store for the offline mode flag.
fn offline_mode_store() -> &'static RwLock<bool> {
    static OFFLINE_MODE: OnceLock<RwLock<bool>> = OnceLock::new();
    OFFLINE_MODE.get_or_init(|| RwLock::new(false))
}

/// Sets the global offline mode.
pub fn set_offline(offline: bool) {
    if let Ok(mut guard) = offline_mode_store().write() {
        *guard = offline;
    }
}

/// Returns true if Zoi is in offline mode.
pub fn is_offline() -> bool {
    offline_mode_store().read().is_ok_and(|g| *g)
}