use crate::data_map::DataMap;
use std::sync::{Arc, Mutex};
#[derive(Clone)]
pub(crate) struct RequestContext {
inner: Arc<Mutex<DataMap>>,
}
impl RequestContext {
pub(crate) fn new() -> Self {
Self {
inner: Arc::new(Mutex::new(DataMap::new())),
}
}
pub(crate) fn set<T: Send + Sync + Clone + 'static>(&self, val: T) {
self.inner.lock().unwrap().insert(val);
}
pub(crate) fn get<T: Send + Sync + Clone + 'static>(&self) -> Option<T> {
self.inner.lock().unwrap().get::<T>().cloned()
}
}