valence_core/
request_cache.rs1use std::collections::HashMap;
4use std::sync::{Arc, Mutex};
5
6#[derive(Clone, Default)]
8pub struct RequestPermissionCache {
9 inner: Arc<Mutex<HashMap<String, bool>>>,
10}
11
12impl RequestPermissionCache {
13 #[must_use]
15 pub fn new() -> Self {
16 Self {
17 inner: Arc::new(Mutex::new(HashMap::new())),
18 }
19 }
20
21 pub fn get(&self, key: &str) -> Option<bool> {
23 self.inner.lock().ok()?.get(key).copied()
24 }
25
26 pub fn set(&self, key: &str, allowed: bool) {
28 if let Ok(mut guard) = self.inner.lock() {
29 guard.insert(key.to_string(), allowed);
30 }
31 }
32}