easy_storage

Crates.ioeasy_storage
lib.rseasy_storage
version0.4.1
created_at2025-08-14 13:50:50.04448+00
updated_at2025-09-16 13:06:13.387881+00
descriptionProvides a trait to easily save and load structs in JSON or TOML format.
homepage
repositoryhttps://github.com/Uliboooo/easy_storage
max_upload_size
id1794899
size15,723
Uliboooo(γ†γ‚ŠγΌγ†) (Uliboooo)

documentation

README

Storeable Crate

A Rust crate that provides a trait for easily saving and loading data structures to and from files in either JSON or TOML format.

Installation

Add the following to your Cargo.toml file:

[dependencies]
easy_storage = "0.3.*"

https://crates.io/crates/easy_storage

Example

use serde::{Deserialize, Serialize};
use easy_storage::Storeable;

#[derive(Debug, Serialize, Deserialize)]
struct User {
    name: String,
    email: String,
}

impl Storeable for User {}

fn main() {
    let user = User {
        name: "Alice".to_string(),
        email: "alice@alice.com".to_string(),
    };
    let save_path = std::env::current_dir().unwrap().join("test").join("user.toml");
    match user.save_by_extension(&save_path, true) {
        Ok(_) => println!("success."),
        Err(e) => println!("Error: {e}"),
    }

    match User::load_by_extension(save_path) {
        Ok(s) => println!("{s:?}"),
        Err(e) => println!("Error: {e}"),
    }
}
Commit count: 19

cargo fmt