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
//! # TinyKV
//!
//! A minimal JSON-based persistent key-value store for Rust projects.
//! Supports optional TTL (expiration), auto-saving, backup, and serialization via `serde` or `nanoserde`.
//! Works in `no_std` environments with `alloc`.
//!
//! ## Features
//! - File-based storage using pretty-formatted JSON
//! - Optional TTL expiration support per key
//! - Auto-saving changes on modification
//! - Backup support with `.bak` files
//! - Simple interface with `serde` (default) or `nanoserde` (feature flag)
//! - `no_std` support with `alloc`
//!
//! ## Feature Flags
//! - `default`: Uses `serde` for serialization (maximum compatibility) and `std`
//! - `nanoserde`: Uses `nanoserde` for minimal binary size and faster compilation
//! - `std`: Enables `std` library (enabled by default)
//!
//! ## Example
//!
//! ```rust
//! use tinykv::TinyKV;
//!
//! # #[cfg(feature = "std")]
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let mut kv = TinyKV::open("mydata.json")?.with_auto_save();
//! kv.set("username", "hasan".to_string())?;
//! kv.set_with_ttl("session_token", "abc123".to_string(), 60)?; // 60 seconds TTL
//! let user: Option<String> = kv.get("username")?;
//! println!("User: {:?}", user);
//! Ok(())
//! }
//!
//! # #[cfg(not(feature = "std"))]
//! # fn main() -> Result<(), tinykv::TinyKVError> {
//! # let mut kv = TinyKV::new();
//! # kv.set("username", "hasan".to_string())?;
//! # let user: Option<String> = kv.get("username")?;
//! # println!("User: {:?}", user);
//! # Ok(())
//! # }
//! ```
extern crate alloc;
// Module declarations
// WASM bindings module
// Public exports - only the essential ones from original
pub use TinyKVError;
pub use TinyKV;
// Re-export WASM types for convenience
pub use WebStorageBackend;
// Re-export important traits for users - exactly as in original
pub use ;
pub use ;