Crates.io | filedb |
lib.rs | filedb |
version | 0.1.2 |
source | src |
created_at | 2018-09-09 18:21:36.955558 |
updated_at | 2018-09-20 13:34:22.017869 |
description | filedb is simple file-based data. It is implementation by rust lang. |
homepage | |
repository | https://github.com/tomo3110/filedb-rs |
max_upload_size | |
id | 83795 |
size | 14,136 |
filedb is simple file-based data.
It becomes a rust version of the golang implementation of the following repository.
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"
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),
}
}