use std::collections::HashMap;
use std::sync::{Arc, Mutex};
#[derive(Clone, Default)]
pub struct RequestPermissionCache {
inner: Arc<Mutex<HashMap<String, bool>>>,
}
impl RequestPermissionCache {
#[must_use]
pub fn new() -> Self {
Self {
inner: Arc::new(Mutex::new(HashMap::new())),
}
}
pub fn get(&self, key: &str) -> Option<bool> {
self.inner.lock().ok()?.get(key).copied()
}
pub fn set(&self, key: &str, allowed: bool) {
if let Ok(mut guard) = self.inner.lock() {
guard.insert(key.to_string(), allowed);
}
}
}