| Crates.io | easy_storage |
| lib.rs | easy_storage |
| version | 0.4.1 |
| created_at | 2025-08-14 13:50:50.04448+00 |
| updated_at | 2025-09-16 13:06:13.387881+00 |
| description | Provides a trait to easily save and load structs in JSON or TOML format. |
| homepage | |
| repository | https://github.com/Uliboooo/easy_storage |
| max_upload_size | |
| id | 1794899 |
| size | 15,723 |
A Rust crate that provides a trait for easily saving and loading data structures to and from files in either JSON or TOML format.
Add the following to your Cargo.toml file:
[dependencies]
easy_storage = "0.3.*"
https://crates.io/crates/easy_storage
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}"),
}
}