heaplet 0.1.0

A small, in-process, Redis-inspired in-memory store for Rust.
Documentation

heaplet

heaplet is an in-process, in-memory data structure library for Rust.

It provides a single Store that maps keys to multiple native data structures (strings, hashes, sets, lists, deques, and sorted sets) through a typed, SDK-style API.

There is no server, no protocol, no networking — everything runs inside your process.


Why heaplet?

heaplet is designed for situations where you want:

  • Redis-like data structures without running Redis Server
  • a type-safe, Rust-native API (no stringly-typed commands)
  • a small, embeddable store for caches, queues, rankings, or ephemeral state
  • predictable behavior with no background threads or services

Features

  • Unified key space with multiple data structures
  • Lazy key-level TTL support
  • Optional blocking list operations
  • Cursor-based scan APIs
  • Pluggable value codec (default: bincode)
  • Fully in-process and synchronous

Installation

[dependencies]
heaplet = "0.1"

Quick Example

use heaplet::Store;

fn main() -> Result<(), heaplet::Error> {
    let store = Store::new();

    // String / KV
    store.kv().set("count", &1_i64)?;
    store.kv().incr("count")?;
    let v: Option<i64> = store.kv().get("count")?;
    assert_eq!(v, Some(2));

    // Hash
    let user = store.hash("user:1");
    user.hset("name", &"alice")?;
    let name: Option<String> = user.hget("name")?;

    // List
    let queue = store.list("queue");
    queue.rpush(&42)?;
    let x: Option<i32> = queue.lpop()?;

    // Sorted set
    let rank = store.zset("rank");
    rank.zadd(100.0, &"tom")?;
    let top: Vec<String> = rank.zrevrange(0, 0)?;

    Ok(())
}

API Design

heaplet exposes structured views instead of flat commands.

Each key is bound to a data-structure-specific handle:

use heaplet::Store;

fn main() -> Result<(), heaplet::Error> {
    let store = Store::new();

    {
        let h = store.hash("user:1");
        h.hset("age", &18)?;
        let age: Option<i32> = h.hget("age")?;
        assert_eq!(age, Some(18));
    }

    Ok(())
}

This provides:

  • strong typing
  • better IDE discoverability
  • clear separation between data structures

Full API details are available in the generated documentation.


Documentation


Non-Goals

  • No Redis protocol compatibility
  • No persistence or replication
  • No distributed operation

heaplet is intentionally local and embedded.


License

MIT