use version::Version;
use self::OsRelease::*;
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum OsRelease {
FeistyFawn,
GutsyGibbon,
HardyHeron,
IntrepidIbex,
JauntyJackalope,
KarmicKoala,
LucidLynx,
MaverickMeerkat,
NattyNarwhal,
OneiricOcelot,
PrecisePangolin,
QuantalQuetzal,
RaringRingtail,
SaucySalamander,
TrustyTahr,
UtopicUnicorn,
VividVervet,
WilyWerewolf,
XenialXerus,
YakketyYak,
ZestyZapus,
ArtfulAardvark,
BionicBeaver,
CosmicCuttlefish,
#[doc(hidden)]
_NonExhaustive,
}
impl<'a> From<OsRelease> for &'a str {
fn from(release: OsRelease) -> Self {
match release {
FeistyFawn => "Feisty Fawn",
GutsyGibbon => "Gutsy Gibbon",
HardyHeron => "Hardy Heron",
IntrepidIbex => "Intrepid Ibex",
JauntyJackalope => "Jaunty Jackalope",
KarmicKoala => "Karmic Koala",
LucidLynx => "Lucid Lynx",
MaverickMeerkat => "Maverick Meerkat",
NattyNarwhal => "Natty Narwhal",
OneiricOcelot => "Oneiric Ocelot",
PrecisePangolin => "Precise Pangolin",
QuantalQuetzal => "Quantal Quetzal",
RaringRingtail => "Raring Ringtail",
SaucySalamander => "Saucy Salamander",
TrustyTahr => "Trusty Tahr",
UtopicUnicorn => "Utopic Unicorn",
VividVervet => "Vivid Vervet",
WilyWerewolf => "Wily Werewolf",
XenialXerus => "Xenial Xerus",
YakketyYak => "Yakkety Yak",
ZestyZapus => "Zesty Zapus",
ArtfulAardvark => "Artful Aardvark",
BionicBeaver => "Bionic Beaver",
CosmicCuttlefish => "Cosmic Cuttlefish",
_NonExhaustive => unsafe { std::hint::unreachable_unchecked() },
}
}
}
impl OsRelease {
pub const MIN: OsRelease = FeistyFawn;
pub const LATEST: OsRelease = CosmicCuttlefish;
fn _new(Version { major, minor, .. }: Version) -> Option<Self> {
match (major, minor) {
(07, 04) => Some(FeistyFawn),
(07, 10) => Some(GutsyGibbon),
(08, 04) => Some(HardyHeron),
(08, 10) => Some(IntrepidIbex),
(09, 04) => Some(JauntyJackalope),
(09, 10) => Some(KarmicKoala),
(10, 04) => Some(LucidLynx),
(10, 10) => Some(MaverickMeerkat),
(11, 04) => Some(NattyNarwhal),
(11, 10) => Some(OneiricOcelot),
(12, 04) => Some(PrecisePangolin),
(12, 10) => Some(QuantalQuetzal),
(13, 04) => Some(RaringRingtail),
(13, 10) => Some(SaucySalamander),
(14, 04) => Some(TrustyTahr),
(14, 10) => Some(UtopicUnicorn),
(15, 04) => Some(VividVervet),
(15, 10) => Some(WilyWerewolf),
(16, 04) => Some(XenialXerus),
(16, 10) => Some(YakketyYak),
(17, 04) => Some(ZestyZapus),
(17, 10) => Some(ArtfulAardvark),
(18, 04) => Some(BionicBeaver),
(18, 10) => Some(CosmicCuttlefish),
_ => None,
}
}
pub fn new<V: Into<Version>>(version: V) -> Option<Self> {
Self::_new(version.into())
}
pub fn min_kernel_version(self) -> Version {
match self {
FeistyFawn => (2, 06, 20),
GutsyGibbon => (2, 06, 22),
HardyHeron => (2, 06, 24),
IntrepidIbex => (2, 06, 27),
JauntyJackalope => (2, 06, 28),
KarmicKoala => (2, 06, 31),
LucidLynx => (2, 06, 32),
MaverickMeerkat => (2, 06, 35),
NattyNarwhal => (2, 06, 38),
OneiricOcelot => (3, 00, 00),
PrecisePangolin => (3, 02, 00),
QuantalQuetzal => (3, 05, 00),
RaringRingtail => (3, 08, 00),
SaucySalamander => (3, 11, 00),
TrustyTahr => (3, 13, 00),
UtopicUnicorn => (3, 16, 00),
VividVervet => (3, 19, 00),
WilyWerewolf => (4, 02, 00),
XenialXerus => (4, 04, 00),
YakketyYak => (4, 08, 00),
ZestyZapus => (4, 10, 00),
ArtfulAardvark => (4, 13, 00),
BionicBeaver => (4, 15, 00),
CosmicCuttlefish => (4, 18, 00),
_NonExhaustive => unsafe { std::hint::unreachable_unchecked() },
}.into()
}
}
impl From<OsRelease> for Version {
fn from(release: OsRelease) -> Version {
match release {
FeistyFawn => (07, 04),
GutsyGibbon => (07, 10),
HardyHeron => (08, 04),
IntrepidIbex => (08, 10),
JauntyJackalope => (09, 04),
KarmicKoala => (09, 10),
LucidLynx => (10, 04),
MaverickMeerkat => (10, 10),
NattyNarwhal => (11, 04),
OneiricOcelot => (11, 10),
PrecisePangolin => (12, 04),
QuantalQuetzal => (12, 10),
RaringRingtail => (13, 04),
SaucySalamander => (13, 10),
TrustyTahr => (14, 04),
UtopicUnicorn => (14, 10),
VividVervet => (15, 04),
WilyWerewolf => (15, 10),
XenialXerus => (16, 04),
YakketyYak => (16, 10),
ZestyZapus => (17, 04),
ArtfulAardvark => (17, 10),
BionicBeaver => (18, 04),
CosmicCuttlefish => (18, 10),
_NonExhaustive => unsafe { std::hint::unreachable_unchecked() },
}.into()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn cmp() {
assert!(OsRelease::LATEST > OsRelease::MIN);
}
}