heaplet/
lib.rs

1//! # heaplet
2//!
3//! A tiny, in-memory, Redis-inspired data structure store for Rust.
4//!
5//! `heaplet` exposes a single [`Store`] that holds multiple Redis-like structures
6//! under one key-space. Most APIs are typed (`T: serde::Serialize` / `T: serde::de::DeserializeOwned`)
7//! and use a pluggable [`codec::Codec`] (default: [`codec::BincodeCodec`]).
8//!
9//! ## Quick start
10//!
11//! ```rust
12//! use heaplet::Store;
13//!
14//! let store = Store::new();
15//!
16//! // KV / String
17//! store.kv().set("k", &123_i64).unwrap();
18//! let v: Option<i64> = store.kv().get("k").unwrap();
19//! assert_eq!(v, Some(123));
20//!
21//! // Hash
22//! let h = store.hash("h");
23//! h.hset("field", &"value").unwrap();
24//! let hv: Option<String> = h.hget("field").unwrap();
25//! assert_eq!(hv.as_deref(), Some("value"));
26//!
27//! // Set
28//! let s = store.set("s");
29//! s.sadd(&"a").unwrap();
30//! assert!(s.sismember(&"a").unwrap());
31//!
32//! // ZSet
33//! let z = store.zset("z");
34//! z.zadd(2.0, &"b").unwrap();
35//! z.zadd(1.0, &"a").unwrap();
36//! let r: Vec<String> = z.zrange(0, -1).unwrap();
37//! assert_eq!(r, vec!["a".to_string(), "b".to_string()]);
38//! ```
39//!
40//! ## Notes
41//! - Expiration is lazy: expired keys are removed when accessed (e.g. `exists`, `get`, `hget`).
42//! - Scan-style APIs (`scan`, `hscan`, `sscan`, `zscan`) are snapshot-based for deterministic paging (MVP).
43pub mod codec;
44pub mod deque;
45pub mod entry;
46pub mod error;
47pub mod hash;
48pub mod keys;
49pub mod kv;
50pub mod list;
51pub mod prelude;
52pub mod set;
53pub mod store;
54pub mod zset;
55
56pub use crate::error::Error;
57pub use crate::store::Store;