zoi-core 1.24.1

Advanced Package Manager & Environment Orchestrator
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::sync::{OnceLock, RwLock};

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().map(|g| *g).unwrap_or(false)
}