use crate::VersionError;
use alloc::string::ToString;
use core::{
fmt::{Display, Formatter},
str::FromStr,
};
mod convert;
#[cfg(feature = "schemars")]
mod json_schema;
#[cfg(feature = "serde")]
mod ser_der;
#[repr(C, align(8))]
#[derive(Copy, Clone, Debug, Default, Ord, PartialOrd, Eq, PartialEq, Hash)]
pub struct Version {
pub year: u32,
pub major: u32,
pub minor: u32,
pub patch: u32,
}
impl Version {
pub const MIN: Version = Version { year: 0, major: 0, minor: 0, patch: 0 };
pub const MAX: Version = Version { year: u32::MAX, major: u32::MAX, minor: u32::MAX, patch: u32::MAX };
pub fn new(year: u32, major: u32, minor: u32, patch: u32) -> Self {
Self { year, major, minor, patch }
}
}
impl Display for Version {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
write!(f, "{}.{}.{}.{}", self.year, self.major, self.minor, self.patch)
}
}