#lmdb #typed #database-storage

heed

A fully typed LMDB (mdb.master) wrapper with minimum overhead

49 releases

0.22.1-nested-rtxns-6 Nov 5, 2025
0.22.1-nested-rtxns Sep 30, 2025
0.22.0 Mar 13, 2025
0.21.0 Dec 6, 2024
0.6.0 Nov 26, 2019

#20 in Database interfaces

Download history 31808/week @ 2025-09-23 34505/week @ 2025-09-30 36447/week @ 2025-10-07 34556/week @ 2025-10-14 40466/week @ 2025-10-21 60322/week @ 2025-10-28 31877/week @ 2025-11-04 31340/week @ 2025-11-11 46522/week @ 2025-11-18 46528/week @ 2025-11-25 44772/week @ 2025-12-02 42256/week @ 2025-12-09 36643/week @ 2025-12-16 15988/week @ 2025-12-23 18542/week @ 2025-12-30 43556/week @ 2026-01-06

121,015 downloads per month
Used in 75 crates (41 directly)

MIT license

1MB
18K SLoC

C 11K SLoC // 0.2% comments Rust 6.5K SLoC // 0.0% comments

heed & heed3

License Crates.io Docs dependency status Build Discord

Rust-centric LMDB abstractions with minimal overhead. These libraries enable the storage of various Rust types within LMDB, extending support to include Serde-compatible types. It supports not only the LMDB mdb.master branch but also the mdb.master3 branch, which features encryption-at-rest.

Simple Example Usage

Here is an example on how to store and read entries into LMDB in a safe and ACID way. For usage examples, see examples/. To see more advanced usage techniques go check our Cookbook.

use std::fs;
use std::path::Path;
use heed::{EnvOpenOptions, Database};
use heed::types::*;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let env = unsafe { EnvOpenOptions::new().open("my-first-db")? };

    // We open the default unnamed database
    let mut wtxn = env.write_txn()?;
    let db: Database<Str, U32<byteorder::NativeEndian>> = env.create_database(&mut wtxn, None)?;

    // We open a write transaction
    db.put(&mut wtxn, "seven", &7)?;
    db.put(&mut wtxn, "zero", &0)?;
    db.put(&mut wtxn, "five", &5)?;
    db.put(&mut wtxn, "three", &3)?;
    wtxn.commit()?;

    // We open a read transaction to check if those values are now available
    let mut rtxn = env.read_txn()?;

    let ret = db.get(&rtxn, "zero")?;
    assert_eq!(ret, Some(0));

    let ret = db.get(&rtxn, "five")?;
    assert_eq!(ret, Some(5));

    Ok(())
}

Working with two Crates: heed and heed3

The heed and heed3 crates manage a shared codebase. Within the heed3 folder, you can find the Cargo.toml specific to the heed3 crate. To facilitate work on heed3, utilize the convert-to-heed3.sh script.

This script conveniently moves the heed3/Cargo.toml file to the heed/ folder, updates the heed:: references to heed3::, and generates a commit for easy rollback if needed.

Building from Source

You can use this command to clone the repository:

git clone --recursive https://github.com/meilisearch/heed.git
cd heed
cargo build

However, if you already cloned it and forgot to initialize the submodules, execute the following command:

git submodule update --init

Dependencies

~0.6–2.6MB
~47K SLoC