Marcel Müller 6e304f7d86 Merge pull request #20 from TheNeikos/add-more_readme
Add self-contained to the readme
2016-10-28 19:59:04 +02:00
2016-10-23 21:13:23 +02:00
2016-10-23 20:20:12 +02:00
2016-10-15 14:38:17 +02:00
2016-10-15 18:14:13 +02:00
2016-10-22 19:17:10 +02:00
2016-10-15 14:38:17 +02:00
2016-10-28 19:03:00 +02:00

Rustbreak

Build Status

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

  • Simple To Use, Fast, Secure
  • Threadsafe
  • Key/Value Storage

Usage

Usage is quite simple:

  • Create/open a database using Database::open
    • You can specify the kind of Key you want using this Syntax: Database::<Key>::open
  • Insert/Retrieve data from the Database
  • Don't forget to run flush periodically
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();
}

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.

S
Description
A simple, fast and easy to use self-contained single file storage for Rust
Readme MPL-2.0 312 KiB
Languages
Rust 100%