| Crates.io | const-struct-version |
| lib.rs | const-struct-version |
| version | 0.2.0 |
| created_at | 2025-03-09 06:59:59.387746+00 |
| updated_at | 2025-03-09 23:00:38.478968+00 |
| description | A trait plus proc-macro to generate a hash based on the fields of a struct. Useful for intelligently expiring a cache when the stored object changes. |
| homepage | |
| repository | https://github.com/JosiahBull/const-struct-version |
| max_upload_size | |
| id | 1585206 |
| size | 136,188 |
This crate has a trait + proc-macro to generate a hash based on the fields of a struct. Useful for intelligently expiring a cache when the stored object changes.
Note that this crate is NOT perfect and may not work for all use cases, especially given our limitations with proc-macros.
Known limitations:
Feel free to open an issue if you have a use case that doesn't work with this crate.
serde-attributes - add #[serde(XXX)] attributes into the generated hash.derive - derive the StructVersion trait for an object automatically.uuid - Support for uuid crate.chrono - Support for chrono crate.indexmap - Support for indexmap crate.url - Support for url crate.[dependencies]
const_struct_version = "0.1"
use const_struct_version::StructVersion;
#[derive(StructVersion)]
pub struct Cart {
items: Vec<String>,
owner: String,
}
fn main() {
println!("Cart version: {}", Cart::version_cached());
}
Contribution are welcome! Please feel free to open an issue or a pull request.
Licensed under either of
at your option.