#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum NotificationLevel {
Info,
Warning,
Alert,
Success,
Error,
}
impl NotificationLevel {
pub fn icon(&self) -> &'static str {
match self {
NotificationLevel::Info => "ℹ",
NotificationLevel::Warning => "⚠",
NotificationLevel::Alert => "🔔",
NotificationLevel::Success => "✓",
NotificationLevel::Error => "✗",
}
}
}
#[derive(Debug, Clone)]
pub struct Notification {
pub level: NotificationLevel,
pub message: String,
pub timestamp_ms: u64,
pub dismissed: bool,
}
impl Notification {
pub fn new(level: NotificationLevel, message: impl Into<String>, timestamp_ms: u64) -> Self {
Self {
level,
message: message.into(),
timestamp_ms,
dismissed: false,
}
}
pub fn info(message: impl Into<String>, timestamp_ms: u64) -> Self {
Self::new(NotificationLevel::Info, message, timestamp_ms)
}
pub fn warning(message: impl Into<String>, timestamp_ms: u64) -> Self {
Self::new(NotificationLevel::Warning, message, timestamp_ms)
}
pub fn alert(message: impl Into<String>, timestamp_ms: u64) -> Self {
Self::new(NotificationLevel::Alert, message, timestamp_ms)
}
pub fn success(message: impl Into<String>, timestamp_ms: u64) -> Self {
Self::new(NotificationLevel::Success, message, timestamp_ms)
}
pub fn error(message: impl Into<String>, timestamp_ms: u64) -> Self {
Self::new(NotificationLevel::Error, message, timestamp_ms)
}
}