use crate::SCHEMA_VERSION;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
pub struct SchemaVersion {
#[cfg_attr(feature = "minicbor", n(0))]
pub major: u32,
#[cfg_attr(feature = "minicbor", n(1))]
pub minor: u32,
}
impl SchemaVersion {
pub const fn new(major: u32, minor: u32) -> Self {
Self { major, minor }
}
pub const fn current() -> Self {
Self {
major: SCHEMA_VERSION,
minor: 0,
}
}
pub fn is_compatible(&self) -> bool {
self.major == SCHEMA_VERSION
}
}
impl Default for SchemaVersion {
fn default() -> Self {
Self::current()
}
}