DisplayColor

Trait DisplayColor 

Source
pub trait DisplayColor: Display + Into<Color> {
    // Provided methods
    fn fmt_background(&self, f: &mut Formatter<'_>) -> Result { ... }
    fn fmt_color(&self, f: &mut Formatter<'_>) -> Result { ... }
    fn background_color(&self) -> String { ... }
    fn color(&self) -> String { ... }
}
Expand description

Converts the type into a Color For the default implementation to work. Display must be implemented with the return type that is compatible with \x1b[{38 || 48};{VALUE}m

The functions below will not check for NO_COLOR automatically. It is recommended that you do this yourself

Provided Methods§

Source

fn fmt_background(&self, f: &mut Formatter<'_>) -> Result

Formats the ansi escape code for the background On the True Color and Eight Bit it will be the Format \x1b[48;{}m on the four bit it will use the \x1b[{}m

This is used when you want to push a direct write to the formatter. If you don’t have a formatter. Use background_color

Source

fn fmt_color(&self, f: &mut Formatter<'_>) -> Result

Formats the ansi escape code for the normal color On the True Color and Eight Bit it will be the Format \x1b[38;{}m on the four bit it will use the \x1b[{}m

This is used when you want to push a direct write to the formatter. If you don’t have a formatter. Use color

Source

fn background_color(&self) -> String

Creates the ANSI escape code as a string

Source

fn color(&self) -> String

Creates the ANSI escape code as a string for the text color

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.

Implementors§