Skip to main content

StyledText

Trait StyledText 

Source
pub trait StyledText: Sized {
Show 63 methods // Required methods fn s<T: Display>(self, s: T) -> Self; fn reset(self) -> Self; fn repeat<T: Display>(self, s: T, n: usize) -> Self; fn plural<T: Display>(self, s: T, n: usize) -> Self; fn align_left<T: Display>(self, s: T, width: usize) -> Self; fn align_right<T: Display>(self, s: T, width: usize) -> Self; fn align_center<T: Display>(self, s: T, width: usize) -> Self; fn pad<T: Display>(self, ch: char, padding: usize, s: T) -> Self; fn pad_left<T: Display>(self, ch: char, s: T, width: usize) -> Self; fn pad_right<T: Display>(self, ch: char, s: T, width: usize) -> Self; fn pad_center<T: Display>(self, ch: char, s: T, width: usize) -> Self; fn fill(self, ch: char, width: usize) -> Self; fn choose<T: Display, F: Display>( self, condition: bool, when_true: T, when_false: F, ) -> Self; fn matches<C: IntoIterator<Item = (bool, impl Display)>>( self, conditions: C, ) -> Self; fn indent<T: Display>(self, indent: usize, s: T) -> Self; fn bold(self) -> Self; fn italic(self) -> Self; fn underline(self) -> Self; fn black(self) -> Self; fn bright_black(self) -> Self; fn red(self) -> Self; fn bright_red(self) -> Self; fn green(self) -> Self; fn bright_green(self) -> Self; fn yellow(self) -> Self; fn bright_yellow(self) -> Self; fn blue(self) -> Self; fn bright_blue(self) -> Self; fn magenta(self) -> Self; fn bright_magenta(self) -> Self; fn cyan(self) -> Self; fn bright_cyan(self) -> Self; fn white(self) -> Self; fn bright_white(self) -> Self; fn bg_black(self) -> Self; fn bg_bright_black(self) -> Self; fn bg_red(self) -> Self; fn bg_bright_red(self) -> Self; fn bg_green(self) -> Self; fn bg_bright_green(self) -> Self; fn bg_yellow(self) -> Self; fn bg_bright_yellow(self) -> Self; fn bg_blue(self) -> Self; fn bg_bright_blue(self) -> Self; fn bg_magenta(self) -> Self; fn bg_bright_magenta(self) -> Self; fn bg_cyan(self) -> Self; fn bg_bright_cyan(self) -> Self; fn bg_white(self) -> Self; fn bg_bright_white(self) -> Self; fn color(self, c: Color) -> Self; fn bright_color(self, c: Color) -> Self; fn bg_color(self, c: Color) -> Self; fn bg_bright_color(self, c: Color) -> Self; fn color_8(self, c: u8) -> Self; fn bright_color_8(self, c: u8) -> Self; fn bg_color_8(self, c: u8) -> Self; fn bg_bright_color_8(self, c: u8) -> Self; fn color_256(self, c: u8) -> Self; fn bg_color_256(self, c: u8) -> Self; fn color_rgb(self, c: RgbColor) -> Self; fn bg_color_rgb(self, c: RgbColor) -> Self; // Provided method fn r<T: Display>(self, s: T) -> Self { ... }
}
Expand description

A trait representing styled text.

Required Methods§

Source

fn s<T: Display>(self, s: T) -> Self

Adds content to text.

Source

fn reset(self) -> Self

Resets all colors and styling flags.

Source

fn repeat<T: Display>(self, s: T, n: usize) -> Self

Adds repeated content to text.

Source

fn plural<T: Display>(self, s: T, n: usize) -> Self

Adds s suffix to the content when the number is not 1.

Source

fn align_left<T: Display>(self, s: T, width: usize) -> Self

Adds the content aligned left with specified width.

Source

fn align_right<T: Display>(self, s: T, width: usize) -> Self

Adds the content aligned right with specified width.

Source

fn align_center<T: Display>(self, s: T, width: usize) -> Self

Adds the content centered with specified width.

Source

fn pad<T: Display>(self, ch: char, padding: usize, s: T) -> Self

Pads the content with specified character.

Source

fn pad_left<T: Display>(self, ch: char, s: T, width: usize) -> Self

Pads the content aligned the left with specified width.

Source

fn pad_right<T: Display>(self, ch: char, s: T, width: usize) -> Self

Pads the content aligned right with specified width.

Source

fn pad_center<T: Display>(self, ch: char, s: T, width: usize) -> Self

Pads the content centered with specified width.

Source

fn fill(self, ch: char, width: usize) -> Self

Fills the content with the given character until the given width is reached.

Source

fn choose<T: Display, F: Display>( self, condition: bool, when_true: T, when_false: F, ) -> Self

Adds new content based on the condition.

Source

fn matches<C: IntoIterator<Item = (bool, impl Display)>>( self, conditions: C, ) -> Self

Adds new content based on the first matching condition.

Source

fn indent<T: Display>(self, indent: usize, s: T) -> Self

Adds indented content.

Source

fn bold(self) -> Self

Style text as bold.

Source

fn italic(self) -> Self

Style text as italic.

Source

fn underline(self) -> Self

Style text as underlined.

Source

fn black(self) -> Self

Sets the foreground color to black.

Source

fn bright_black(self) -> Self

Sets the foreground color to bright black.

Source

fn red(self) -> Self

Sets the foreground color to red.

Source

fn bright_red(self) -> Self

Sets the foreground color to bright red.

Source

fn green(self) -> Self

Sets the foreground color to green.

Source

fn bright_green(self) -> Self

Sets the foreground color to bright green.

Source

fn yellow(self) -> Self

Sets the foreground color to yellow.

Source

fn bright_yellow(self) -> Self

Sets the foreground color to bright yellow.

Source

fn blue(self) -> Self

Sets the foreground color to blue.

Source

fn bright_blue(self) -> Self

Sets the foreground color to bright blue.

Source

fn magenta(self) -> Self

Sets the foreground color to magenta.

Source

fn bright_magenta(self) -> Self

Sets the foreground color to bright magenta.

Source

fn cyan(self) -> Self

Sets the foreground color to cyan.

Source

fn bright_cyan(self) -> Self

Sets the foreground color to bright cyan.

Source

fn white(self) -> Self

Sets the foreground color to white.

Source

fn bright_white(self) -> Self

Sets the foreground color to bright white.

Source

fn bg_black(self) -> Self

Sets the background color to black.

Source

fn bg_bright_black(self) -> Self

Sets the background color to bright black.

Source

fn bg_red(self) -> Self

Sets the background color to red.

Source

fn bg_bright_red(self) -> Self

Sets the background color to bright red.

Source

fn bg_green(self) -> Self

Sets the background color to green.

Source

fn bg_bright_green(self) -> Self

Sets the background color to bright green.

Source

fn bg_yellow(self) -> Self

Sets the background color to yellow.

Source

fn bg_bright_yellow(self) -> Self

Sets the background color to bright yellow.

Source

fn bg_blue(self) -> Self

Sets the background color to blue.

Source

fn bg_bright_blue(self) -> Self

Sets the background color to bright blue.

Source

fn bg_magenta(self) -> Self

Sets the background color to magenta.

Source

fn bg_bright_magenta(self) -> Self

Sets the background color to bright magenta.

Source

fn bg_cyan(self) -> Self

Sets the background color to cyan.

Source

fn bg_bright_cyan(self) -> Self

Sets the background color to bright cyan.

Source

fn bg_white(self) -> Self

Sets the background color to white.

Source

fn bg_bright_white(self) -> Self

Sets the background color to bright white.

Source

fn color(self, c: Color) -> Self

Sets the color by color enumeration.

Source

fn bright_color(self, c: Color) -> Self

Sets the bright color by color enumeration.

Source

fn bg_color(self, c: Color) -> Self

Sets the background color by color enumeration.

Source

fn bg_bright_color(self, c: Color) -> Self

Sets the background bright color by color enumeration.

Source

fn color_8(self, c: u8) -> Self

Sets the color by color index.

Source

fn bright_color_8(self, c: u8) -> Self

Sets the bright color by color index.

Source

fn bg_color_8(self, c: u8) -> Self

Sets the background color by color index.

Source

fn bg_bright_color_8(self, c: u8) -> Self

Sets the background bright color by color index.

Source

fn color_256(self, c: u8) -> Self

Source

fn bg_color_256(self, c: u8) -> Self

Source

fn color_rgb(self, c: RgbColor) -> Self

Source

fn bg_color_rgb(self, c: RgbColor) -> Self

Provided Methods§

Source

fn r<T: Display>(self, s: T) -> Self

Resets all styling and then appends formatted content.

This is equivalent to calling text.reset().s(value).

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§