#[allow(missing_docs)] #[non_exhaustive]
#[derive(
::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::Ord, ::std::cmp::PartialEq, ::std::cmp::PartialOrd, ::std::fmt::Debug, ::std::hash::Hash,
)]
pub enum Severity {
#[allow(missing_docs)] Critical,
#[allow(missing_docs)] High,
#[allow(missing_docs)] Info,
#[allow(missing_docs)] Low,
#[allow(missing_docs)] Medium,
#[deprecated(note = "Don't directly match on `Unknown`. See the docs on this enum for the correct way to handle unknown variants.")]
Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue),
}
impl ::std::convert::From<&str> for Severity {
fn from(s: &str) -> Self {
match s {
"Critical" => Severity::Critical,
"High" => Severity::High,
"Info" => Severity::Info,
"Low" => Severity::Low,
"Medium" => Severity::Medium,
other => Severity::Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue(other.to_owned())),
}
}
}
impl ::std::str::FromStr for Severity {
type Err = ::std::convert::Infallible;
fn from_str(s: &str) -> ::std::result::Result<Self, <Self as ::std::str::FromStr>::Err> {
::std::result::Result::Ok(Severity::from(s))
}
}
impl Severity {
pub fn as_str(&self) -> &str {
match self {
Severity::Critical => "Critical",
Severity::High => "High",
Severity::Info => "Info",
Severity::Low => "Low",
Severity::Medium => "Medium",
Severity::Unknown(value) => value.as_str(),
}
}
pub const fn values() -> &'static [&'static str] {
&["Critical", "High", "Info", "Low", "Medium"]
}
}
impl ::std::convert::AsRef<str> for Severity {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl Severity {
pub fn try_parse(value: &str) -> ::std::result::Result<Self, crate::error::UnknownVariantError> {
match Self::from(value) {
#[allow(deprecated)]
Self::Unknown(_) => ::std::result::Result::Err(crate::error::UnknownVariantError::new(value)),
known => Ok(known),
}
}
}
impl ::std::fmt::Display for Severity {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
match self {
Severity::Critical => write!(f, "Critical"),
Severity::High => write!(f, "High"),
Severity::Info => write!(f, "Info"),
Severity::Low => write!(f, "Low"),
Severity::Medium => write!(f, "Medium"),
Severity::Unknown(value) => write!(f, "{value}"),
}
}
}