use std::collections::HashMap; use async_trait::async_trait; use tokio::sync::Mutex; #[async_trait] pub trait KvStore: Send + Sync { async fn get(&self, key: &str) -> Option; async fn set(&self, key: &str, value: String); } #[derive(Debug, Default)] pub struct MemoryKvStore { inner: Mutex>, } #[async_trait] impl KvStore for MemoryKvStore { async fn get(&self, key: &str) -> Option { self.inner.lock().await.get(key).cloned() } async fn set(&self, key: &str, value: String) { self.inner.lock().await.insert(key.to_string(), value); } }