//! In-memory mock key-value store for testing vault logic (native only) use kvstore::KVStore; use std::collections::HashMap; use std::sync::{Arc, Mutex}; #[derive(Clone, Default)] pub struct MockStore { inner: Arc>>>, } #[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))] #[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)] impl KVStore for MockStore { async fn get(&self, key: &str) -> Result>, kvstore::KVError> { Ok(self.inner.lock().unwrap().get(key).cloned()) } async fn set(&self, key: &str, value: &[u8]) -> Result<(), kvstore::KVError> { self.inner.lock().unwrap().insert(key.to_string(), value.to_vec()); Ok(()) } async fn remove(&self, key: &str) -> Result<(), kvstore::KVError> { self.inner.lock().unwrap().remove(key); Ok(()) } async fn contains_key(&self, key: &str) -> Result { Ok(self.inner.lock().unwrap().contains_key(key)) } async fn keys(&self) -> Result, kvstore::KVError> { Ok(self.inner.lock().unwrap().keys().cloned().collect()) } async fn clear(&self) -> Result<(), kvstore::KVError> { self.inner.lock().unwrap().clear(); Ok(()) } }