#key-value-database #cdb #bindings

tinycdb

Bindings to the TinyCDB C library (http://www.corpit.ru/mjt/tinycdb.html)

7 releases

Uses old Rust 2015

0.0.7 Dec 19, 2015
0.0.6 Nov 19, 2015
0.0.5 Apr 4, 2015
0.0.4 Mar 31, 2015
0.0.3 Nov 20, 2014

#2401 in Database interfaces

Download history 6/week @ 2024-02-19 11/week @ 2024-02-26 4/week @ 2024-03-04 8/week @ 2024-03-11 1/week @ 2024-03-18 118/week @ 2024-04-01

128 downloads per month
Used in cdbd

MIT license

155KB
3K SLoC

C 1.5K SLoC // 0.1% comments Rust 1K SLoC // 0.2% comments Shell 114 SLoC // 0.1% comments RPM Specfile 70 SLoC // 0.0% comments

tinycdb-rs

Build Status Coverage Status Docs

This project consists of Rust bindings to tinycdb, a small library for creating and reading constant key-value databases.

Example

Add this to your Cargo.toml:

[dependencies.tinycdb]

git = "https://github.com/andrew-d/tinycdb-rs"

Then, in your crate:

extern crate tinycdb;

use tinycdb::base::Cdb;

Reading a database:

let path = Path::new("test.cdb");

let mut db = match Cdb::open(&path) {
    Ok(db) => db,
    Err(why) => panic!("Could not open CDB: {}", why),
};

match db.find(b"foo") {
    Some(val) => println!("Value of 'foo' key is: {}", val),
    None      => println!("'foo' key was not found"),
};

Creating a database:

let path = Path::new("created.cdb");

let res = Cdb::new(&path, |creator| {
    let r = creator.add(b"foo", b"bar");
    assert!(r.is_ok());
});

let mut db = match res {
    Ok(db)   => db,
    Err(why) => panic!("Could not create database: {}", why),
};

// Now, use 'db' as normal...

License

MIT (the original code of TinyCDB is in the public domain)

Dependencies