#[non_exhaustive]pub enum Severity {
Info,
Warning,
Error,
Fatal,
}Expand description
Severity level for errors, warnings, and notifications.
Severity represents how serious a problem is and how it should be handled.
It is used throughout the error system and integrates with the notification
system for user-facing alerts.
§Variants
| Level | Meaning | Shell Behavior |
|---|---|---|
Info | Informational, not a problem | Log only |
Warning | Suboptimal but functional | Log + optional notification |
Error | Operation failed | Log + notification + retry possible |
Fatal | Unrecoverable | Log + notification + exit |
§Ordering
Severity implements Ord, with Info being the least
severe and Fatal being the most:
use fernctl::error::Severity;
assert!(Severity::Info < Severity::Warning);
assert!(Severity::Warning < Severity::Error);
assert!(Severity::Error < Severity::Fatal);§Display
Each severity has both a human-readable name and an icon for terminal output:
use fernctl::error::Severity;
assert_eq!(Severity::Error.as_str(), "error");
assert_eq!(Severity::Error.icon(), "✗");§Serialization
Severity serializes to lowercase strings for JSON/TOML compatibility:
use fernctl::error::Severity;
let json = serde_json::to_string(&Severity::Warning).unwrap();
assert_eq!(json, "\"warning\"");Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Info
Informational message, not an error.
Use for status updates, progress information, or optional suggestions that don’t indicate any problem.
§Example Scenarios
- “Configuration loaded successfully”
- “Using default theme”
- “3 modules active”
Warning
Something is suboptimal but will work.
Use when the configuration or operation has issues that should be addressed, but the shell can continue functioning.
§Example Scenarios
- Unknown configuration key (will be ignored)
- Deprecated option used
- Fallback to default value
Error
Operation failed, but recovery is possible.
Use when a specific operation or module fails, but the shell as a whole can continue. The user should be notified and may need to take action.
§Example Scenarios
- Invalid color format in config
- Module failed to load
- Network request timed out
Fatal
Implementations§
Source§impl Severity
impl Severity
Sourcepub const fn as_str(&self) -> &'static str
pub const fn as_str(&self) -> &'static str
Returns the string representation of this severity.
The returned string is lowercase and suitable for logging or serialization.
§Examples
use fernctl::error::Severity;
assert_eq!(Severity::Info.as_str(), "info");
assert_eq!(Severity::Warning.as_str(), "warning");
assert_eq!(Severity::Error.as_str(), "error");
assert_eq!(Severity::Fatal.as_str(), "fatal");Sourcepub const fn icon(&self) -> &'static str
pub const fn icon(&self) -> &'static str
Returns a Unicode icon representing this severity.
These icons are designed for terminal output and provide quick visual identification of severity levels.
§Examples
use fernctl::error::Severity;
assert_eq!(Severity::Info.icon(), "ℹ");
assert_eq!(Severity::Warning.icon(), "⚠");
assert_eq!(Severity::Error.icon(), "✗");
assert_eq!(Severity::Fatal.icon(), "💀");§Terminal Output
ℹ Configuration loaded
⚠ Unknown key 'colour' (did you mean 'color'?)
✗ Invalid color format: #gg0000
💀 Cannot start: config.toml is not valid TOMLSourcepub const fn ansi_color(&self) -> &'static str
pub const fn ansi_color(&self) -> &'static str
Returns an ANSI color code for terminal styling.
These codes are suitable for colorizing terminal output. Use with
\x1b[0m to reset styling.
§Colors
| Severity | Color |
|---|---|
| Info | Blue |
| Warning | Yellow |
| Error | Red |
| Fatal | Magenta (bright) |
§Example
use fernctl::error::Severity;
let sev = Severity::Error;
let reset = "\x1b[0m";
println!("{}{} Something went wrong{}", sev.ansi_color(), sev.icon(), reset);Sourcepub const fn is_error(&self) -> bool
pub const fn is_error(&self) -> bool
Returns true if this severity indicates an error condition.
An error condition is either Error or
Fatal. This is useful for deciding whether
to fail an operation.
§Examples
use fernctl::error::Severity;
assert!(!Severity::Info.is_error());
assert!(!Severity::Warning.is_error());
assert!(Severity::Error.is_error());
assert!(Severity::Fatal.is_error());Trait Implementations§
Source§impl Default for Severity
impl Default for Severity
Source§fn default() -> Self
fn default() -> Self
Returns Severity::Info as the default severity.
Source§impl<'de> Deserialize<'de> for Severity
impl<'de> Deserialize<'de> for Severity
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 Ord for Severity
impl Ord for Severity
Source§impl PartialOrd for Severity
impl PartialOrd for Severity
impl Copy for Severity
impl Eq for Severity
impl StructuralPartialEq for Severity
Auto Trait Implementations§
impl Freeze for Severity
impl RefUnwindSafe for Severity
impl Send for Severity
impl Sync for Severity
impl Unpin for Severity
impl UnwindSafe for Severity
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<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§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