use std::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum AdvisorySeverity {
Info,
Caution,
}
impl AdvisorySeverity {
pub fn as_str(self) -> &'static str {
match self {
Self::Info => "info",
Self::Caution => "caution",
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Advisory {
pub severity: AdvisorySeverity,
pub message: String,
}
impl Advisory {
pub fn info(message: impl Into<String>) -> Self {
Self {
severity: AdvisorySeverity::Info,
message: message.into(),
}
}
pub fn caution(message: impl Into<String>) -> Self {
Self {
severity: AdvisorySeverity::Caution,
message: message.into(),
}
}
}
impl fmt::Display for Advisory {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(&self.message)
}
}