#bindings #cdb #key #find #tinycdb #tiny-cdb

sys tinycdb-sys

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

2 releases

Uses old Rust 2015

0.0.2 Apr 4, 2015
0.0.1 Mar 31, 2015

#12 in #cdb


Used in 2 crates (via tinycdb)

MIT license

110KB
2K SLoC

C 1.5K SLoC // 0.1% comments Shell 115 SLoC // 0.1% comments Rust 110 SLoC // 0.3% comments RPM Specfile 71 SLoC // 0.1% comments

Contains (ELF exe/lib, 27KB) deps/tinycdb-0.78/cdb, (static library, 26KB) deps/tinycdb-0.78/libcdb.a, (static library, 27KB) deps/tinycdb-0.78/libcdb_pic.a, (ELF exe/lib, 3KB) deps/tinycdb-0.78/cdb_find.lo, (ELF exe/lib, 3KB) deps/tinycdb-0.78/cdb_findnext.lo, (ELF exe/lib, 2KB) deps/tinycdb-0.78/cdb_hash.lo and 7 more.

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