Crates.io | koit-toml |
lib.rs | koit-toml |
version | 0.2.1 |
source | src |
created_at | 2021-05-20 04:14:06.964919 |
updated_at | 2021-05-20 04:44:04.366038 |
description | A simple, asynchronous, pure-Rust, structured, embedded database |
homepage | |
repository | https://github.com/tomcur/koit |
max_upload_size | |
id | 399841 |
size | 25,070 |
Koit is a simple, asynchronous, pure-Rust, structured, embedded database.
[dependencies]
koit = "0.2"
use std::default::Default;
use koit::{FileDatabase, format::Toml};
use serde::{Deserialize, Serialize};
#[derive(Default, Deserialize, Serialize)]
struct Data {
cats: u64,
yaks: u64,
}
#[async_std::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let db = FileDatabase::<Data, Toml>::load_from_path_or_default("./db.toml").await?;
db.write(|data| {
data.cats = 10;
data.yaks = 32;
}).await;
assert_eq!(db.read(|data| data.cats + data.yaks).await, 42);
db.save().await?;
Ok(())
}
By default, Koit comes with its file-backend, JSON / Toml formatter and Bincode formatter enabled. You can cherry-pick features instead.
[dependencies.koit]
version = "0.2"
default-features = false
features = ["toml-format"]
Koit enables quickly implementing persistence and concurrent access to structured data. It is meant to be used with relatively small amounts (megabytes) of data.
It is not a performant database. Upon loading, the entire data structure is kept in memory. Upon saving, the entire data structure is formatted and written to the storage backend.
Koit is inspired by Rustbreak, a similar (synchronous) database.
This project is licensed under the MIT license.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Koit by you, shall be licensed as MIT, without any additional terms or conditions.