mecha10-core 0.6.2

Mecha10 core runtime and foundational types
Documentation
//! In-memory `StateManager` backend (not persistent across restarts).

use super::StateSnapshot;
use std::collections::HashMap;
use std::sync::Arc;
use tokio::sync::RwLock;

/// In-memory state storage (not persistent across restarts)
#[derive(Clone)]
pub struct MemoryStateManager {
    pub(super) states: Arc<RwLock<HashMap<String, Vec<u8>>>>,
    #[allow(clippy::type_complexity)]
    pub(super) snapshots: Arc<RwLock<HashMap<String, (Vec<u8>, StateSnapshot)>>>,
}

impl MemoryStateManager {
    /// Create new in-memory state manager
    pub fn new() -> Self {
        Self {
            states: Arc::new(RwLock::new(HashMap::new())),
            snapshots: Arc::new(RwLock::new(HashMap::new())),
        }
    }
}

impl Default for MemoryStateManager {
    fn default() -> Self {
        Self::new()
    }
}