Const-struct-version
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:
- Custom derivations that have special logic we can't see.
- Objects that are inherently unstable/mutable.
- Struct/Enum names that are significant to the versioning.
Feel free to open an issue if you have a use case that doesn't work with this crate.
Features
serde-attributes
- add #[serde(XXX)] attributes into the generated hash.derive
- derive theStructVersion
trait for an object automatically.uuid
- Support foruuid
crate.chrono
- Support forchrono
crate.indexmap
- Support forindexmap
crate.url
- Support forurl
crate.
Usage
[]
= "0.1"
use StructVersion;
Contribution
Contribution are welcome! Please feel free to open an issue or a pull request.
License
Licensed under either of
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
at your option.