tinycdb

Crates.iotinycdb
lib.rstinycdb
version0.0.7
sourcesrc
created_at2014-11-20 22:19:29.9762
updated_at2015-12-19 15:16:45.679868
descriptionBindings to the TinyCDB C library (http://www.corpit.ru/mjt/tinycdb.html)
homepage
repositoryhttps://github.com/andrew-d/tinycdb-rs
max_upload_size
id170
size32,088
Andrew Dunham (andrew-d)

documentation

http://rust-ci.org/andrew-d/tinycdb-rs/doc/tinycdb/

README

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)

Commit count: 81

cargo fmt