crio

Crates.iocrio
lib.rscrio
version2.0.5
sourcesrc
created_at2022-03-18 16:29:42.344839
updated_at2022-06-28 11:35:38.033742
descriptionAn easy to use persistent data storage library
homepagehttps://github.com/tropicbliss/crio
repositoryhttps://github.com/tropicbliss/crio
max_upload_size
id552773
size15,364
tropicbliss (tropicbliss)

documentation

https://docs.rs/crio

README

Persistent Data Container

An easy to use persistent data storage library. Integrates well with serde.

Usage

use crio::Client;
use serde_derive::{Deserialize, Serialize};

#[derive(Serialize, Deserialize)]
struct Message {
    id: usize,
    message: String,
}

let msg1 = Message {
    id: 1,
    message: "Hello there, you suck".to_string(),
};
let msg2 = Message {
    id: 2,
    message: "No you".to_string(),
};
let msg3 = Message {
    id: 3,
    message: "You both suck".to_string(),
};
let messages = vec![msg1, msg2, msg3];
let client: Client<Message> = Client::new("messages", false)?; // If no file is found, a new empty file is created.
client.write_many(&messages)?; // If no file is found, a new file is created and then written to. Append is set to false such that it overwrites any previous value stored on the same file
let returned_messages = client.load()?;
if let Some(data) = returned_messages {
    assert_eq!(messages, data);
} else {
    panic!("File is empty");
}
Commit count: 132

cargo fmt