serde-semver: Serde-compatible version checker
The crate lets you build a version checker using declare_version
macro.
It is useful to create a versioned configuration with a version number audited during deserialization.
Usage
For example, declare a MyVersion
checker with the semver requirement ^3.5.11
.
!;
declare_version
We can embed it in the configuration struct. In the following code, it audits the version number in the JSON text.
use Version;
use ;
use PathBuf;
// Declare the checker type that asserts '3.5.11'
declare_version!;
// An example configuration with version tag
// The version number is audited during deserialization.
let config: Config = from_str
.unwrap;
// The original version is recovered after serialization.
assert_eq!;
// Besides deserialization, the version tag can also be created from scratch.
let my_ver = new.unwrap;
License
MIT license. See LICENSE.txt file.