arma_rs/context/
global.rs1use std::sync::Arc;
2
3use crate::{ContextState, State};
4
5pub struct GlobalContext {
7 version: String,
8 state: Arc<State>,
9}
10
11impl GlobalContext {
12 pub(crate) fn new(version: String, state: Arc<State>) -> Self {
13 Self { version, state }
14 }
15
16 #[must_use]
17 pub fn version(&self) -> &str {
19 &self.version
20 }
21}
22
23impl ContextState for GlobalContext {
24 fn get<T>(&self) -> Option<&T>
25 where
26 T: Send + Sync + 'static,
27 {
28 self.state.try_get()
29 }
30
31 fn set<T>(&self, value: T) -> bool
32 where
33 T: Send + Sync + 'static,
34 {
35 self.state.set(value)
36 }
37}