3 releases

0.7.1 Mar 21, 2024
0.7.0 Jan 25, 2024
0.7.0-alpha.1 Jan 6, 2024

#799 in Database interfaces

Download history 485/week @ 2024-01-06 167/week @ 2024-01-13 54/week @ 2024-01-20 90/week @ 2024-01-27 47/week @ 2024-02-03 1/week @ 2024-02-10 36/week @ 2024-02-17 156/week @ 2024-02-24 188/week @ 2024-03-02 185/week @ 2024-03-09 301/week @ 2024-03-16 428/week @ 2024-03-23 135/week @ 2024-03-30 13/week @ 2024-04-06

880 downloads per month

Unlicense

38KB
408 lines

cdb

Crate

This library provides pure Rust support for reading and writing CDB files. A CDB file is a constant key-value on-disk hash table, designed for high-speed lookups.

This is a fork of the cdb-rs crate.

Documentation

License

The Unlicense


lib.rs:

This crate provides support for reading and writing CDB files. A CDB is a "constant database" that acts as an on-disk associative array mapping keys to values, allowing multiple values for each key. It provides for fast lookups and low overheads. A constant database has no provision for updating, only rewriting from scratch.

Examples

Reading a set of records:

use cdb2::CDB;

let cdb = CDB::open("tests/test1.cdb")?;
for result in cdb.find(b"one") {
    println!("{:?}", result?);
}

Creating a database with safe atomic updating:

use cdb2::CDBWriter;

let mut cdb = CDBWriter::create("temporary.cdb")?;
cdb.add(b"one", b"Hello, ")?;
cdb.add(b"one", b"world!\n")?;
cdb.add(b"two", &[1, 2, 3, 4])?;
cdb.finish()?;

References

Dependencies

~165KB