//! Key-Value Store functionality //! //! This module provides a simple key-value store with encryption support. //! //! The implementation uses different backends depending on the platform: //! - For WebAssembly: IndexedDB through the `IndexedDbStore` type //! - For native platforms: SlateDB through the `SlateDbStore` type //! //! All implementations share the same interface defined by the `KVStore` trait. mod error; mod store; mod key_space; mod slate_store; mod indexed_db_store; // Re-export public types and functions pub use error::{KvsError, Result}; pub use store::{KvPair, KVStore}; // Re-export the SlateDbStore for native platforms pub use slate_store::{ SlateDbStore, create_slatedb_store, open_slatedb_store, delete_slatedb_store, list_slatedb_stores }; // Re-export the IndexedDbStore for WebAssembly #[cfg(target_arch = "wasm32")] pub use indexed_db_store::{ IndexedDbStore, create_indexeddb_store, open_indexeddb_store }; // Define the default store type based on platform #[cfg(target_arch = "wasm32")] pub type DefaultStore = IndexedDbStore; #[cfg(not(target_arch = "wasm32"))] pub type DefaultStore = SlateDbStore; // Re-export key_space functionality pub use key_space::{ load_key_space, create_key_space, save_key_space, list_key_spaces, delete_key_space }; // Platform-specific open/create functions that return the appropriate DefaultStore #[cfg(target_arch = "wasm32")] pub async fn open_default_store(name: &str, password: Option<&str>) -> Result { open_indexeddb_store(name, password).await } #[cfg(not(target_arch = "wasm32"))] pub fn open_default_store(name: &str, password: Option<&str>) -> Result { open_slatedb_store(name, password) } #[cfg(target_arch = "wasm32")] pub async fn create_default_store(name: &str, encrypted: bool, password: Option<&str>) -> Result { create_indexeddb_store(name, encrypted).await } #[cfg(not(target_arch = "wasm32"))] pub fn create_default_store(name: &str, encrypted: bool, password: Option<&str>) -> Result { create_slatedb_store(name, encrypted, password) }