Rustbreak

Build Status Crates Link

Documentation

Rustbreak is an [Daybreak] inspired self-contained file database. It is meant to be fast and simple to use. You add it to your application and it should just work for you. The only thing you will have to take care of is saving.

When to use it

This library started out because of a need to be able to quickly write an application in rust that needed some persistence while still being able to write arbitrary data to it.

In Ruby there is [Daybreak] however for Rust there was no similar crate, until now!

Features

Usage

Usage is quite simple:

```rust use rustbreak::Database;

fn main() { let db = Database::open("my_contacts").unwrap();

db.insert("Lapfox", "lapfoxtrax.com").unwrap();
db.insert("Rust", "github.com/rust-lang/rust").unwrap();

// we need to be explicit about the kind of type we want as println! is
// generic
let rust : String = db.retrieve("Rust").unwrap();
println!("You can find Rust at: {}", rust);
db.flush().unwrap();

} ```

Yaml

If you would like to use yaml instead of bincode to perhaps read or modify the database in an editor you can use it like this:

toml [dependencies.rustbreak] version = "1" default-features = false features = ["yaml"]

Ron

If you would like to use ron instead of bincode:

toml [dependencies.rustbreak] version = "1" default-features = false features = ["ron_enc"]

How it works

Internally the Database holds a Hashmap behind a RwLock. This Hashmap is then written to/read from and safely casted to the requested type. This works thanks to encoding/decoding traits.