pub struct Notification {
pub severity: Severity,
pub title: String,
pub body: String,
pub suggestion: Option<String>,
pub code: Option<String>,
pub timestamp: SystemTime,
}Expand description
A notification ready to be sent to the desktop notification service.
Notification is a plain data struct containing all information needed
to display a notification. It is serializable for IPC transmission.
§Creating Notifications
Notifications are typically created from types implementing Notifiable:
let notification = error.to_notification();But you can also create them directly:
let notification = Notification::new(
Severity::Info,
"Config Loaded",
"Successfully loaded configuration from config.toml",
);§Serialization
Notifications serialize to JSON for D-Bus transmission:
let json = serde_json::to_string(¬ification)?;
// {"severity":"info","title":"...","body":"...",...}Fields§
§severity: SeveritySeverity level determining visual presentation.
title: StringShort title for the notification header.
body: StringDetailed body text.
suggestion: Option<String>Optional actionable suggestion.
code: Option<String>Optional error code for documentation lookup.
timestamp: SystemTimeWhen the notification was created.
Implementations§
Source§impl Notification
impl Notification
Sourcepub fn new(
severity: Severity,
title: impl Into<String>,
body: impl Into<String>,
) -> Self
pub fn new( severity: Severity, title: impl Into<String>, body: impl Into<String>, ) -> Self
Creates a new notification with the given severity, title, and body.
§Arguments
severity— How serious is this notificationtitle— Short summary for the headerbody— Detailed explanation
§Example
use fernctl::error::{Notification, Severity};
let notification = Notification::new(
Severity::Info,
"Config Loaded",
"Successfully loaded configuration",
);Sourcepub fn info(title: impl Into<String>, body: impl Into<String>) -> Self
pub fn info(title: impl Into<String>, body: impl Into<String>) -> Self
Creates an informational notification.
Convenience constructor for Severity::Info notifications.
§Example
use fernctl::error::Notification;
let notification = Notification::info("Config Loaded", "All modules initialized");Sourcepub fn warning(title: impl Into<String>, body: impl Into<String>) -> Self
pub fn warning(title: impl Into<String>, body: impl Into<String>) -> Self
Creates a warning notification.
Convenience constructor for Severity::Warning notifications.
§Example
use fernctl::error::Notification;
let notification = Notification::warning(
"Unknown Key",
"Configuration contains unknown key 'colour'",
);Sourcepub fn error(title: impl Into<String>, body: impl Into<String>) -> Self
pub fn error(title: impl Into<String>, body: impl Into<String>) -> Self
Creates an error notification.
Convenience constructor for Severity::Error notifications.
§Example
use fernctl::error::Notification;
let notification = Notification::error(
"Invalid Color",
"Color '#gg0000' is not valid hex",
);Sourcepub fn with_suggestion(self, suggestion: impl Into<String>) -> Self
pub fn with_suggestion(self, suggestion: impl Into<String>) -> Self
Adds a suggestion to this notification.
§Example
use fernctl::error::Notification;
let notification = Notification::error("Invalid Color", "...")
.with_suggestion("Use hex format: #RRGGBB");Sourcepub fn with_code(self, code: impl Into<String>) -> Self
pub fn with_code(self, code: impl Into<String>) -> Self
Adds an error code to this notification.
§Example
use fernctl::error::Notification;
let notification = Notification::error("Invalid Color", "...")
.with_code("fern::config::invalid_color");Sourcepub fn is_error(&self) -> bool
pub fn is_error(&self) -> bool
Returns true if this notification indicates an error condition.
§Example
use fernctl::error::{Notification, Severity};
let info = Notification::info("Test", "Test");
let error = Notification::error("Test", "Test");
assert!(!info.is_error());
assert!(error.is_error());Trait Implementations§
Source§impl Clone for Notification
impl Clone for Notification
Source§fn clone(&self) -> Notification
fn clone(&self) -> Notification
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Notification
impl Debug for Notification
Source§impl<'de> Deserialize<'de> for Notification
impl<'de> Deserialize<'de> for Notification
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for Notification
impl Display for Notification
Source§impl PartialEq for Notification
impl PartialEq for Notification
Source§impl Serialize for Notification
impl Serialize for Notification
impl StructuralPartialEq for Notification
Auto Trait Implementations§
impl Freeze for Notification
impl RefUnwindSafe for Notification
impl Send for Notification
impl Sync for Notification
impl Unpin for Notification
impl UnwindSafe for Notification
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg] or
a color-specific method, such as [OwoColorize::green], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg] or
a color-specific method, such as [OwoColorize::on_yellow], Read more