Expand description
heed
is a high-level wrapper of LMDB.
The cookbook will give you a variety of complete Rust programs to use with heed.
This crate simply facilitates the use of LMDB by providing a mechanism to store and retrieve Rust types. It abstracts away some of the complexities of the raw LMDB usage while retaining its performance characteristics. The functionality is achieved with the help of the serde library for data serialization concerns.
LMDB stands for Lightning Memory-Mapped Database, which utilizes memory-mapped files
for efficient data storage and retrieval by mapping file content directly into the virtual
address space. heed
derives its efficiency from the underlying LMDB without imposing
additional runtime costs.
§Examples
Open a database that will support some typed key/data and ensure, at compile time, that you’ll write those types and not others.
use std::fs;
use std::path::Path;
use heed::{EnvOpenOptions, Database};
use heed::types::*;
let dir = tempfile::tempdir()?;
let env = unsafe { EnvOpenOptions::new().open(dir.path())? };
// we will open the default unnamed database
let mut wtxn = env.write_txn()?;
let db: Database<Str, U32<byteorder::NativeEndian>> = env.create_database(&mut wtxn, None)?;
// opening 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()?;
// opening 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));
Re-exports§
pub use byteorder;
pub use heed_types as types;
Modules§
- A cookbook of examples on how to use heed. Here is the list of the different topics you can learn about:
- The set of possible iteration methods for the different iterators.
Structs§
- A typed database that accepts only the types it was created with.
- LMDB database flags (see http://www.lmdb.tech/doc/group__mdb__dbi__open.html for more details).
- Options and flags which can be used to configure how a
Database
is opened. - Statistics for a database in the environment.
- An environment handle constructed by using
EnvOpenOptions
. - A structure that can be used to wait for the closing event. Multiple threads can wait on this event.
- LMDB environment flags (see http://www.lmdb.tech/doc/group__mdb__env.html for more details).
- Contains information about the environment.
- Options and flags which can be used to configure how an environment is opened.
- The underlying LMDB library version information.
- LMDB put flags (see http://www.lmdb.tech/doc/group__mdb.html#ga4fa8573d9236d54687c61827ebf8cac0 or http://www.lmdb.tech/doc/group__mdb.html#ga1f83ccb40011837ff37cc32be01ad91e for more details).
- A structure that is used to improve the write speed in LMDB.
- A read-only iterator structure.
- A read-only prefix iterator structure.
- A read-only range iterator structure.
- A reverse read-only iterator structure.
- A reverse read-only prefix iterator structure.
- A reverse read-only range iterator structure.
- A read-only transaction.
- A read-write iterator structure.
- A read-write prefix iterator structure.
- A read-write range iterator structure.
- A reverse read-write iterator structure.
- A reverse read-write prefix iterator structure.
- A reverse read-write range iterator structure.
- A read-write transaction.
Enums§
- Whether to perform compaction while copying an environment.
- A representation of LMDB’s default comparator behavior.
- An error that encapsulates all possible errors in this crate.
- Whether to enable or disable flags in
Env::set_flags
. - An LMDB error kind.
- An unspecified type.
Traits§
- A trait that represents a decoding structure.
- A trait that represents an encoding structure.
- Define a custom key comparison function for a database.
- Define a lexicographic comparator, which is a special case of
Comparator
.
Functions§
- Returns a struct that allows to wait for the effective closing of an environment.
- Return the LMDB library version information.
Type Aliases§
- A boxed
Send + Sync + 'static
error. - Either a success or an
Error
.