mecha10_core/state/
memory.rs1use super::StateSnapshot;
4use std::collections::HashMap;
5use std::sync::Arc;
6use tokio::sync::RwLock;
7
8#[derive(Clone)]
9pub struct MemoryStateManager {
10 pub(super) states: Arc<RwLock<HashMap<String, Vec<u8>>>>,
11 #[allow(clippy::type_complexity)]
12 pub(super) snapshots: Arc<RwLock<HashMap<String, (Vec<u8>, StateSnapshot)>>>,
13}
14
15impl MemoryStateManager {
16 pub fn new() -> Self {
18 Self {
19 states: Arc::new(RwLock::new(HashMap::new())),
20 snapshots: Arc::new(RwLock::new(HashMap::new())),
21 }
22 }
23}
24
25impl Default for MemoryStateManager {
26 fn default() -> Self {
27 Self::new()
28 }
29}