1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//! RKVS - Rust Key-Value Storage
//!
//! A high-performance, namespace-based key-value storage system built in Rust.
//! Provides persistent storage with configurable limits, async operations, and atomic batch processing.
//!
//! # Features
//!
//! - **High Performance**: Optimized for speed with async operations and efficient data structures.
//! - **Namespace Support**: Organize data into isolated namespaces with individual configurations.
//! - **Automatic Sharding**: Keys are automatically distributed across multiple shards for improved concurrency.
//! - **Optional Auto-Scaling**: Namespaces can automatically increase their shard count as data grows.
//! - **Atomic Batch Operations**: Perform `set`, `get`, and `delete` on multiple items with all-or-nothing semantics.
//! - **Persistence**: Optional file-based persistence with automatic serialization.
//! - **Thread-Safe**: Built on Tokio's async primitives for concurrent access.
//! - **Convenience Methods**: Includes atomic operations like `consume` (get and delete) and `update` (fail if key doesn't exist).
//!
//! # Quick Start
//!
//! ```rust
//! use rkvs::{StorageManager, NamespaceConfig, Result};
//! use std::env::temp_dir;
//!
//! #[tokio::main]
//! async fn main() -> Result<()> {
//! // Use a temporary directory. The persistence layer will create it if it doesn't exist.
//! let temp_path = temp_dir().join("rkvs_docs_lib_main");
//!
//! let storage = StorageManager::builder()
//! .with_persistence(temp_path)
//! .build().await?;
//!
//! // Initialize the storage
//! storage.initialize(None).await?;
//!
//! // Create a namespace with configuration
//! let mut config = NamespaceConfig::default();
//! config.set_max_keys(1000);
//! config.set_max_value_size(1024 * 1024); // 1MB
//! storage.create_namespace("my_app", Some(config)).await?;
//!
//! // Get the namespace handle
//! let namespace = storage.namespace("my_app").await?;
//!
//! // Store data
//! namespace.set("user:123", b"John Doe".to_vec()).await?;
//!
//! // Retrieve data
//! if let Some(data) = namespace.get("user:123").await {
//! println!("User: {}", String::from_utf8_lossy(&data));
//! }
//!
//! Ok(())
//! }
//! ```
//!
//! # Batch Operations
//!
//! RKVS supports efficient batch operations for processing multiple key-value pairs:
//! ```rust
//! use rkvs::{StorageManager, Result, BatchMode};
//!
//! # async fn run() -> Result<()> {
//! # let storage = StorageManager::builder().build().await?;
//! # storage.initialize(None).await?;
//! # storage.create_namespace("my_app", None).await?;
//! # let namespace = storage.namespace("my_app").await?;
//!
//! // Batch set multiple items
//! let items = vec![
//! ("key1".to_string(), b"value1".to_vec()),
//! ("key2".to_string(), b"value2".to_vec()),
//! ("key3".to_string(), b"value3".to_vec()),
//! ];
//!
//! let result = namespace.set_multiple(items, BatchMode::BestEffort).await;
//!
//! // Check for errors by inspecting the `errors` field.
//! if result.errors.is_none() {
//! println!("Set {} items successfully", result.total_processed);
//! }
//!
//! Ok(())
//! }
//! ```
// Re-export commonly used types
pub use ;
pub use *;
pub use *;
pub use *;
pub use *;