Crates.io | keratin |
lib.rs | keratin |
version | 0.3.0 |
source | src |
created_at | 2020-10-04 21:13:43.510129 |
updated_at | 2024-06-04 01:47:12.441214 |
description | A quick setup/quick development, embedded, modular database |
homepage | |
repository | https://github.com/hellbound22/keratin |
max_upload_size | |
id | 296143 |
size | 53,391 |
Keratin is designed from the start to be simple but expansive. Works with any serializable and deserializable struct.
In the future you'll be able to choose how to structure Keratin: how you'll interact with it, what format of persistant data you'll use, attach your own custom modules for data treatment...
WIP!!! Probably don't use in production
Run tests with cargo test -- --test-threads 1
use keratin::*;
fn main() -> Result<()> {
// Choose your method of storage (Anything that implements the 'StorageEngine' trait should work)
let se = keratin::storage::LocalFsStorage;
// Create the collection (using None as the parameter defaults to a directory inside the project)
let mut coll: Collection<String> = Collection::configure(None, &se)?;
// Insert the data into the collection
let result = coll.insert("key", "something".to_owned())?;
assert!(result.is_ok());
// Get the data from the collection
let retrieved_data = coll.get(key).unwrap();
assert_eq!(retrieved_data, "something");
// Delete the entry
coll.delete(&key)?;
// Modify the data entry
coll.modify("key", "another something".to_owned())?;
let retrieved_data = coll.get("key").unwrap();
assert_eq!(retrieved_data, "another something");
}
project folder ---src/
|
|-Cargo.toml
|
|-target/
|
|-db/---------keratin.toml (config)
|
|-data/ ------- BSON documents