summaryrefslogtreecommitdiff
path: root/src/metadata.rs
diff options
context:
space:
mode:
authorKim Altintop <kim@eagain.io>2023-03-29 13:20:08 +0200
committerKim Altintop <kim@eagain.io>2023-03-29 13:20:08 +0200
commita483cc97d56a770c4ccf91dfccf790a8c2d0c9fa (patch)
treeabe1fc1860def1b5f2cceae4c4da003c2f60705d /src/metadata.rs
parenta4d2d6ac8acb34314fba166d5b85ff06c97f0ca3 (diff)
core: version each metadata type separately
It turns out to be preferable to be able to break one type without affecting the other. So instead of the global SpecVersion, use a separate FmtVersion for each type. For compatibility, keep supporting spec_version fields (until next major bump of the respective types' version). Signed-off-by: Kim Altintop <kim@eagain.io>
Diffstat (limited to 'src/metadata.rs')
-rw-r--r--src/metadata.rs26
1 files changed, 8 insertions, 18 deletions
diff --git a/src/metadata.rs b/src/metadata.rs
index 9caee96..2da268f 100644
--- a/src/metadata.rs
+++ b/src/metadata.rs
@@ -56,13 +56,9 @@ pub use identity::{
};
#[derive(Clone, Eq, Ord, PartialEq, PartialOrd)]
-pub struct SpecVersion(SemVer);
-
-impl SpecVersion {
- pub const fn current() -> Self {
- Self::new(0, 1, 0)
- }
+pub struct FmtVersion(SemVer);
+impl FmtVersion {
const fn new(major: u32, minor: u32, patch: u32) -> Self {
Self(SemVer {
major,
@@ -92,19 +88,13 @@ impl SpecVersion {
}
}
-impl Default for SpecVersion {
- fn default() -> Self {
- Self::current()
- }
-}
-
-impl fmt::Display for SpecVersion {
+impl fmt::Display for FmtVersion {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.0.fmt(f)
}
}
-impl FromStr for SpecVersion {
+impl FromStr for FmtVersion {
type Err = <SemVer as FromStr>::Err;
fn from_str(s: &str) -> Result<Self, Self::Err> {
@@ -112,7 +102,7 @@ impl FromStr for SpecVersion {
}
}
-impl<'a> TryFrom<&'a str> for SpecVersion {
+impl<'a> TryFrom<&'a str> for FmtVersion {
type Error = <SemVer as TryFrom<&'a str>>::Error;
fn try_from(value: &str) -> Result<Self, Self::Error> {
@@ -120,13 +110,13 @@ impl<'a> TryFrom<&'a str> for SpecVersion {
}
}
-impl AsRef<SemVer> for SpecVersion {
+impl AsRef<SemVer> for FmtVersion {
fn as_ref(&self) -> &SemVer {
&self.0
}
}
-impl serde::Serialize for SpecVersion {
+impl serde::Serialize for FmtVersion {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
@@ -135,7 +125,7 @@ impl serde::Serialize for SpecVersion {
}
}
-impl<'de> serde::Deserialize<'de> for SpecVersion {
+impl<'de> serde::Deserialize<'de> for FmtVersion {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,