pub struct Colors;Expand description
Theme-aware color wrapper.
Use these instead of direct .green(), .red(), etc. to respect the active theme.
Each method takes a string and a Theme, returning a styled string that
adapts to the theme’s color palette.
§Example
use netspeed_cli::theme::{Colors, Theme};
// Monochrome always returns plain text (no ANSI escapes)
assert_eq!(Colors::good("OK", Theme::Monochrome), "OK");
assert_eq!(Colors::warn("caution", Theme::Monochrome), "caution");
assert_eq!(Colors::bad("FAIL", Theme::Monochrome), "FAIL");
assert_eq!(Colors::info("note", Theme::Monochrome), "note");
// Other themes add ANSI styling but always preserve the original text
assert!(Colors::good("OK", Theme::Dark).contains("OK"));
assert!(Colors::bad("FAIL", Theme::Light).contains("FAIL"));Implementations§
Source§impl Colors
impl Colors
Sourcepub fn good(s: &str, theme: Theme) -> String
pub fn good(s: &str, theme: Theme) -> String
Good/success color.
Green in Dark/HighContrast/Light themes, plain text in Monochrome.
§Example
use netspeed_cli::theme::{Colors, Theme};
// Monochrome: plain text
assert_eq!(Colors::good("100 Mbps", Theme::Monochrome), "100 Mbps");
// Dark/Light/HighContrast: styled with green (contains the text)
assert!(Colors::good("100 Mbps", Theme::Dark).contains("100 Mbps"));
assert!(Colors::good("100 Mbps", Theme::Light).contains("100 Mbps"));Sourcepub fn warn(s: &str, theme: Theme) -> String
pub fn warn(s: &str, theme: Theme) -> String
Warning/caution color.
Yellow in Dark/HighContrast/Light themes, plain text in Monochrome.
§Example
use netspeed_cli::theme::{Colors, Theme};
assert_eq!(Colors::warn("high latency", Theme::Monochrome), "high latency");
assert!(Colors::warn("high latency", Theme::Dark).contains("high latency"));Sourcepub fn bad(s: &str, theme: Theme) -> String
pub fn bad(s: &str, theme: Theme) -> String
Error/bad color.
Red in Dark/HighContrast/Light themes, plain text in Monochrome.
§Example
use netspeed_cli::theme::{Colors, Theme};
assert_eq!(Colors::bad("FAILED", Theme::Monochrome), "FAILED");
assert!(Colors::bad("FAILED", Theme::Dark).contains("FAILED"));Sourcepub fn info(s: &str, theme: Theme) -> String
pub fn info(s: &str, theme: Theme) -> String
Info/neutral color (cyan/blue).
Cyan in Dark/HighContrast, blue in Light, plain text in Monochrome.
§Example
use netspeed_cli::theme::{Colors, Theme};
assert_eq!(Colors::info("Server: 1234", Theme::Monochrome), "Server: 1234");
assert!(Colors::info("Server: 1234", Theme::Dark).contains("Server: 1234"));
assert!(Colors::info("Server: 1234", Theme::Light).contains("Server: 1234"));Sourcepub fn dimmed(s: &str, theme: Theme) -> String
pub fn dimmed(s: &str, theme: Theme) -> String
Dimmed/secondary text.
Dimmed in Dark/Light, plain text in HighContrast/Monochrome (kept readable at high contrast).
§Example
use netspeed_cli::theme::{Colors, Theme};
// Monochrome and HighContrast: plain text (readability over style)
assert_eq!(Colors::dimmed("secondary", Theme::Monochrome), "secondary");
assert_eq!(Colors::dimmed("secondary", Theme::HighContrast), "secondary");
// Dark/Light: dimmed styling (contains the text)
assert!(Colors::dimmed("secondary", Theme::Dark).contains("secondary"));
assert!(Colors::dimmed("secondary", Theme::Light).contains("secondary"));Sourcepub fn bold(s: &str, _theme: Theme) -> String
pub fn bold(s: &str, _theme: Theme) -> String
Bold/emphasized text.
Always applies bold regardless of theme (theme parameter reserved for future theme-specific bold behavior).
§Example
use netspeed_cli::theme::{Colors, Theme};
// Bold always contains the original text
assert!(Colors::bold("important", Theme::Dark).contains("important"));
assert!(Colors::bold("important", Theme::Light).contains("important"));
assert!(Colors::bold("important", Theme::Monochrome).contains("important"));Sourcepub fn muted(s: &str, theme: Theme) -> String
pub fn muted(s: &str, theme: Theme) -> String
Muted/secondary text (bright_black equivalent).
Bright black in Dark/HighContrast, dimmed in Light, plain in Monochrome.
§Example
use netspeed_cli::theme::{Colors, Theme};
// Monochrome: plain text
assert_eq!(Colors::muted("hint", Theme::Monochrome), "hint");
// Other themes contain the original text
assert!(Colors::muted("hint", Theme::Dark).contains("hint"));
assert!(Colors::muted("hint", Theme::Light).contains("hint"));
assert!(Colors::muted("hint", Theme::HighContrast).contains("hint"));Sourcepub fn header(s: &str, theme: Theme) -> String
pub fn header(s: &str, theme: Theme) -> String
Header/section title color.
Cyan+bold+underline in Dark/HighContrast, blue+bold+underline in Light, plain text in Monochrome (no color/underline).
§Example
use netspeed_cli::theme::{Colors, Theme};
// Monochrome: plain text (no color/underline)
assert!(Colors::header("Results", Theme::Monochrome).contains("Results"));
// Dark: cyan + bold + underline
assert!(Colors::header("Results", Theme::Dark).contains("Results"));
// Light: blue + bold + underline
assert!(Colors::header("Results", Theme::Light).contains("Results"));Auto Trait Implementations§
impl Freeze for Colors
impl RefUnwindSafe for Colors
impl Send for Colors
impl Sync for Colors
impl Unpin for Colors
impl UnsafeUnpin for Colors
impl UnwindSafe for Colors
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§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 moreSource§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