clash-verge/src-tauri/src/data/mod.rs

33 lines
673 B
Rust
Raw Normal View History

2022-09-11 15:58:55 +03:00
mod clash;
mod prfitem;
mod profiles;
mod verge;
pub use self::clash::*;
pub use self::prfitem::*;
pub use self::profiles::*;
pub use self::verge::*;
2022-10-27 20:02:47 +03:00
use once_cell::sync::OnceCell;
2022-09-11 15:58:55 +03:00
use parking_lot::Mutex;
use std::sync::Arc;
#[derive(Debug, Clone)]
pub struct Data {
pub clash: Arc<Mutex<Clash>>,
pub verge: Arc<Mutex<Verge>>,
pub profiles: Arc<Mutex<Profiles>>,
}
impl Data {
2022-10-27 20:02:47 +03:00
pub fn global() -> &'static Data {
static DATA: OnceCell<Data> = OnceCell::new();
DATA.get_or_init(|| Data {
clash: Arc::new(Mutex::new(Clash::new())),
verge: Arc::new(Mutex::new(Verge::new())),
profiles: Arc::new(Mutex::new(Profiles::new())),
})
2022-09-11 15:58:55 +03:00
}
}