Skip to main content

Color

Trait Color 

Source
pub trait Color {
    // Required methods
    fn bold(&self) -> String;
    fn italic(&self) -> String;
    fn warn(&self) -> String;
    fn error(&self) -> String;
    fn debug(&self) -> String;
    fn info(&self) -> String;
}
Expand description

Extension trait that adds ANSI color-formatting methods to any Display type.

This is intended for use inside log! calls to highlight important parts of a message. All methods return a new String with the appropriate ANSI escape codes applied.

§Examples

use webdav_server::log::Color;

let msg = "something went wrong".error();
let user = "user_42".bold();

Required Methods§

Source

fn bold(&self) -> String

Wraps the value in bold ANSI escape codes.

Source

fn italic(&self) -> String

Wraps the value in italic (dim) ANSI escape codes.

Source

fn warn(&self) -> String

Wraps the value in yellow ANSI escape codes, used for warnings.

Source

fn error(&self) -> String

Wraps the value in red ANSI escape codes, used for errors.

Source

fn debug(&self) -> String

Wraps the value in grey ANSI escape codes, used for low-priority debug output.

Source

fn info(&self) -> String

Wraps the value in cyan ANSI escape codes, used for informational messages.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T> Color for T
where T: Display,