| Crates.io | save-load-derive |
| lib.rs | save-load-derive |
| version | 0.1.2 |
| created_at | 2025-03-31 04:48:17.791262+00 |
| updated_at | 2025-07-13 10:17:39.009495+00 |
| description | `save-load-derive` is a procedural macro crate enabling automatic derivation of asynchronous file save and load functionalities for structs, leveraging `serde` serialization and `tokio` for async operations. |
| homepage | |
| repository | https://github.com/klebs6/klebs-general |
| max_upload_size | |
| id | 1613015 |
| size | 57,904 |
save-load-derive is a Rust crate designed to streamline file serialization and deserialization processes for custom types by utilizing procedural macros. It automatically generates implementations for the SaveToFile and LoadFromFile traits using serde for serialization and tokio for asynchronous file operations.
SaveToFile and LoadFromFile implementations, reducing boilerplate.tokio to facilitate asynchronous reading from and writing to files, enhancing performance in I/O bound tasks.serde to support the versatile serialization and deserialization of types.SaveLoadError type.To use the save-load-derive crate, apply the SaveLoad derive macro to your structs:
use save_load_derive::SaveLoad;
#[derive(SaveLoad)]
struct MyData {
// your fields here
}
Ensure your type derives or implements serde::Serialize and for<'de> serde::Deserialize<'de> for the macro to succeed without compile errors due to missing trait bounds.
use save_load_derive::SaveLoad;
use serde::{Serialize, Deserialize};
#[derive(SaveLoad, Serialize, Deserialize)]
struct ExampleStruct {
field1: String,
field2: i32,
}
// In asynchronous contexts:
async fn process() -> Result<(), SaveLoadError> {
let data = ExampleStruct {
field1: "data".into(),
field2: 42,
};
data.save_to_file("example.json").await?;
let loaded_data = ExampleStruct::load_from_file("example.json").await?;
Ok(())
}
This crate is licensed under the MIT License.
Note: This README was generated by an AI model and may not be 100% accurate, although it aims to be comprehensive and useful.