#simple #db #kvs #file-base

filedb

filedb is simple file-based data. It is implementation by rust lang.

1 unstable release

0.1.0 Sep 9, 2018

#15 in #db

Download history 31/week @ 2018-09-14 13/week @ 2018-09-21 11/week @ 2018-09-28 4/week @ 2018-10-05 4/week @ 2018-10-12 11/week @ 2018-10-19 3/week @ 2018-10-26 10/week @ 2018-11-02 21/week @ 2018-11-09

1 downloads per month

MIT license

13KB
228 lines

filedb

Build Status filedb at crates.io filedb at docs.rs

filedb is simple file-based data.
It becomes a rust version of the golang implementation of the following repository.

https://github.com/matryer/filedb

Install

Add the following to your

Cargo.toml

[package]
name = "some-project"
version = "1.0.0"
authors = ["my name <hoge@fuga.com>"]

[dependencies]
filedb = "0.1.2"

Usage

main.rs

extern crate filedb;

use filedb::FileDB;
use filedb::callback::*;

fn main() {
    let mut db = FileDB::connect("/tmp/db").unwrap();
    let mut col = match db.c("documents") {
        Ok(c) => c.lock().unwrap(),
        Err(err) => {
            println!("[filedb] failed instance col struct.");
            return;
        },
    };
    let res = col.for_each(|index, data| { 
        println!("index: {}, text: {}", index, String::from_utf8(&data).unwrap());

        ForEachResultValue::new(false)
    });

    match res {
        Ok(_) => println!("[filedb] success!"),
        Err(err) => println!("[filedb] errror... {:?}", err),
    }
}

Dependencies

~1MB
~12K SLoC