use deno_core::anyhow::bail;
use deno_core::error::AnyError;
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum ReleaseChannel {
#[allow(unused)]
Stable,
#[allow(unused)]
Canary,
#[allow(unused)]
Lts,
#[allow(unused)]
Rc,
}
impl ReleaseChannel {
#[allow(unused)]
pub fn name(&self) -> &str {
match self {
Self::Stable => "stable",
Self::Canary => "canary",
Self::Rc => "release candidate",
Self::Lts => "long term support",
}
}
#[allow(unused)]
pub fn serialize(&self) -> String {
match self {
Self::Stable => "stable",
Self::Canary => "canary",
Self::Rc => "rc",
Self::Lts => "lts",
}
.to_string()
}
#[allow(unused)]
pub fn deserialize(str_: &str) -> Result<Self, AnyError> {
Ok(match str_ {
"stable" => Self::Stable,
"canary" => Self::Canary,
"rc" => Self::Rc,
"lts" => Self::Lts,
unknown => bail!("Unrecognized release channel: {}", unknown),
})
}
}