Styleable

Trait Styleable 

Source
pub trait Styleable: Display {
Show 17 methods // Required method fn style_with(&self, styler: impl Styler) -> StyledString; // Provided methods fn error(&self) -> StyledString { ... } fn warning(&self) -> StyledString { ... } fn success(&self) -> StyledString { ... } fn info(&self) -> StyledString { ... } fn emphasis(&self) -> StyledString { ... } fn code(&self) -> StyledString { ... } fn normal(&self) -> StyledString { ... } fn subtle(&self) -> StyledString { ... } fn hint(&self) -> StyledString { ... } fn debug(&self) -> StyledString { ... } fn link(&self) -> StyledString { ... } fn quote(&self) -> StyledString { ... } fn commentary(&self) -> StyledString { ... } fn heading1(&self) -> StyledString { ... } fn heading2(&self) -> StyledString { ... } fn heading3(&self) -> StyledString { ... }
}
Expand description

Trait that allows strings to be styled directly with automatic context preservation

§Examples

use thag_styling::{Role, Styleable};

let styled = "error message".style_with(Role::Error);
let nested = format!("Warning: {}", "critical".error()).warning();

Required Methods§

Source

fn style_with(&self, styler: impl Styler) -> StyledString

Style this text using the given styler, returning a StyledString

Provided Methods§

Source

fn error(&self) -> StyledString

Style this text as an error message

Source

fn warning(&self) -> StyledString

Style this text as a warning message

Source

fn success(&self) -> StyledString

Style this text as a success message

Source

fn info(&self) -> StyledString

Style this text as an informational message

Source

fn emphasis(&self) -> StyledString

Style this text as emphasized text

Source

fn code(&self) -> StyledString

Style this text as code

Source

fn normal(&self) -> StyledString

Style this text as normal text

Source

fn subtle(&self) -> StyledString

Style this text as subtle text

Source

fn hint(&self) -> StyledString

Style this text as hint text

Source

fn debug(&self) -> StyledString

Style this text as debug information

Style this text as a link

Source

fn quote(&self) -> StyledString

Style this text as quoted content

Source

fn commentary(&self) -> StyledString

Style this text as commentary or explanatory notes

Source

fn heading1(&self) -> StyledString

Style this text as a primary heading

Source

fn heading2(&self) -> StyledString

Style this text as a secondary heading

Source

fn heading3(&self) -> StyledString

Style this text as a tertiary heading

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Styleable for &str

Source§

fn style_with(&self, styler: impl Styler) -> StyledString

Source§

impl Styleable for bool

Source§

fn style_with(&self, styler: impl Styler) -> StyledString

Source§

impl Styleable for char

Source§

fn style_with(&self, styler: impl Styler) -> StyledString

Source§

impl Styleable for f32

Source§

fn style_with(&self, styler: impl Styler) -> StyledString

Source§

impl Styleable for f64

Source§

fn style_with(&self, styler: impl Styler) -> StyledString

Source§

impl Styleable for i32

Source§

fn style_with(&self, styler: impl Styler) -> StyledString

Source§

impl Styleable for i64

Source§

fn style_with(&self, styler: impl Styler) -> StyledString

Source§

impl Styleable for isize

Source§

fn style_with(&self, styler: impl Styler) -> StyledString

Source§

impl Styleable for u32

Source§

fn style_with(&self, styler: impl Styler) -> StyledString

Source§

impl Styleable for u64

Source§

fn style_with(&self, styler: impl Styler) -> StyledString

Source§

impl Styleable for usize

Source§

fn style_with(&self, styler: impl Styler) -> StyledString

Source§

impl Styleable for String

Source§

fn style_with(&self, styler: impl Styler) -> StyledString

Source§

impl Styleable for Display<'_>

Source§

fn style_with(&self, styler: impl Styler) -> StyledString

Implementors§