1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use std::sync::Arc;

use crate::{ContextState, State};

/// Contains information about the current group
pub struct GroupContext {
    state: Arc<State>,
}

impl GroupContext {
    pub(crate) fn new(state: Arc<State>) -> Self {
        Self { state }
    }
}

impl ContextState for GroupContext {
    fn get<T>(&self) -> Option<&T>
    where
        T: Send + Sync + 'static,
    {
        self.state.try_get()
    }

    fn set<T>(&self, value: T) -> bool
    where
        T: Send + Sync + 'static,
    {
        self.state.set(value)
    }
}