2 unstable releases

Uses old Rust 2015

0.6.0 Oct 26, 2018
0.5.0 Jan 11, 2016

#2063 in Database interfaces

Download history 370/week @ 2024-07-20 340/week @ 2024-07-27 314/week @ 2024-08-03 531/week @ 2024-08-10 361/week @ 2024-08-17 219/week @ 2024-08-24 284/week @ 2024-08-31 115/week @ 2024-09-07 275/week @ 2024-09-14 198/week @ 2024-09-21 50/week @ 2024-09-28 183/week @ 2024-10-05 125/week @ 2024-10-12 281/week @ 2024-10-19 323/week @ 2024-10-26 136/week @ 2024-11-02

888 downloads per month
Used in reflicate

Unlicense

39KB
383 lines

cdb

Crate Build Status

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.

Documentation

License

Public Domain


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:

let cdb = cdb::CDB::open("tests/test1.cdb").unwrap();

for result in cdb.find(b"one") {
    println!("{:?}", result.unwrap());
}

Creating a database with safe atomic updating:

fn main() -> std::io::Result<()> {
    let mut cdb = 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()?;
    Ok(())
}

References

Dependencies

~235KB