From 531dc44da3e4477ac9ffe9ca4b7ea26605acddfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=BCller?= Date: Thu, 12 Oct 2017 22:03:48 +0200 Subject: [PATCH] Add some documentation --- src/lib.rs | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 8eda640..5ffa59f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,10 +23,52 @@ //! //! Rustbreak is a [Daybreak][daybreak] inspiried single file Database. //! -//! See the [examples][examples] to get an idea how this library is used. +//! You will find an overview here in the docs, but to give you a more complete tale of how this is +//! used please check the [examples][examples]. +//! +//! At its core, Rustbreak is an attempt at making a configurable key-value store Database. +//! It features the possibility of: +//! - Choosing what kind of Data is stored in it +//! - What kind of Container is storing it +//! - Which kind of Serialization is used for persistence +//! - Which kind of persistence is used +//! +//! Per default these options are used: +//! - The Container is a HashMap, leaving you the choice what you want to store in it, and +//! can access it with a String key. +//! - The Serialization is [Ron][ron], a familiar notation for Rust +//! - The persistence is in-memory, allowing for quick prototyping +//! +//! Later in the development process, the Serialization and the Persistence can be exchanged without +//! breaking the code, allowing you to be flexible. +//! +//! If you have any questions feel free to ask at the main [repo][repo]. +//! +//! ## Quickstart +//! +//! ```rust +//! use rustbreak::Database; +//! +//! let db = Database::memory(); +//! +//! println!("Writing to Database"); +//! db.write(|mut db| { +//! db.insert("hello".into(), String::from("world")); +//! db.insert("foo".into(), String::from("bar")); +//! }); +//! +//! db.read(|db| { +//! // db.insert("foo".into(), String::from("bar")); +//! // The above line will not compile since we are only reading +//! println!("Hello: {:?}", db.get("hello")); +//! }); +//! ``` //! //! [daybreak]:https://propublica.github.io/daybreak -//! [examples]: https://github.com/TheNeikos/rustbreak +//! [examples]: https://github.com/TheNeikos/rustbreak/tree/master/examples +//! [examples]: https://github.com/TheNeikos/rustbreak/ +//! [ron]: https://github.com/ron-rs/ron + extern crate serde; extern crate ron;