zoi_core/frozen.rs
1use std::sync::{OnceLock, RwLock};
2
3/// Returns the global store for the frozen mode flag.
4fn frozen_mode_store() -> &'static RwLock<bool> {
5 static FROZEN_MODE: OnceLock<RwLock<bool>> = OnceLock::new();
6 FROZEN_MODE.get_or_init(|| RwLock::new(false))
7}
8
9/// Sets the global frozen mode.
10pub fn set_frozen(frozen: bool) {
11 if let Ok(mut guard) = frozen_mode_store().write() {
12 *guard = frozen;
13 }
14}
15
16/// Returns true if Zoi is in frozen mode.
17pub fn is_frozen() -> bool {
18 frozen_mode_store().read().is_ok_and(|g| *g)
19}