#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Concern {
Exposure,
Caution,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Notice {
pub concern: Concern,
pub message: String,
}
impl Notice {
pub fn exposure(message: impl Into<String>) -> Self {
Self {
concern: Concern::Exposure,
message: message.into(),
}
}
pub fn caution(message: impl Into<String>) -> Self {
Self {
concern: Concern::Caution,
message: message.into(),
}
}
pub fn for_table(mut self, table: &str) -> Self {
self.message = format!("table '{table}': {}", self.message);
self
}
}
impl std::fmt::Display for Notice {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(&self.message)
}
}