Style

Struct Style 

Source
pub struct Style { /* private fields */ }
Expand description

A Stylized text that can be output to a terminal.

§Examples

    let s = Style::new(format!("{}, {}!", "Hello", "world"))
                .black()
                .underline()
                .to_string();
    assert_eq!(s, "\x1b[30;4mHello, world!\x1b[0m");

Implementations§

Source§

impl Style

Source

pub fn new(text: String) -> Self

Create a new style whose text is the given text.

Source

pub fn bold(&mut self) -> &mut Self

Apply a bold value to the escape sequence.

Source

pub fn faint(&mut self) -> &mut Self

Apply a faint value to the escape sequence.

Source

pub fn italic(&mut self) -> &mut Self

Apply an italic value to the escape sequence.

Source

pub fn underline(&mut self) -> &mut Self

Apply an underline value to the escape sequence.

Apply a slow blink value to the escape sequence.

Apply a fast blink value to the escape sequence.

Source

pub fn reverse(&mut self) -> &mut Self

Apply a reverse value to the escape sequence.

Source

pub fn conceal(&mut self) -> &mut Self

Apply a conceal value to the escape sequence.

Source

pub fn strikethrough(&mut self) -> &mut Self

Apply a strikethrough value to the escape sequence.

Source

pub fn black(&mut self) -> &mut Self

Apply the foreground color black value to the escape sequence.

Source

pub fn red(&mut self) -> &mut Self

Apply the foreground color red value to the escape sequence.

Source

pub fn green(&mut self) -> &mut Self

Apply the foreground color green value to the escape sequence.

Source

pub fn yellow(&mut self) -> &mut Self

Apply the foreground color yellow value to the escape sequence.

Source

pub fn blue(&mut self) -> &mut Self

Apply the foreground color blue value to the escape sequence.

Source

pub fn magenta(&mut self) -> &mut Self

Apply the foreground color magenta value to the escape sequence.

Source

pub fn cyan(&mut self) -> &mut Self

Apply the foreground color cyan value to the escape sequence.

Source

pub fn white(&mut self) -> &mut Self

Apply the foreground color white value to the escape sequence.

Source

pub fn gray(&mut self) -> &mut Self

Apply the foreground color gray value to the escape sequence.

Source

pub fn bright_red(&mut self) -> &mut Self

Apply the foreground color bright red value to the escape sequence.

Source

pub fn bright_green(&mut self) -> &mut Self

Apply the foreground color bright green value to the escape sequence.

Source

pub fn bright_yellow(&mut self) -> &mut Self

Apply the foreground color bright yellow value to the escape sequence.

Source

pub fn bright_blue(&mut self) -> &mut Self

Apply the foreground color bright blue value to the escape sequence.

Source

pub fn bright_magenta(&mut self) -> &mut Self

Apply the foreground color bright magenta value to the escape sequence.

Source

pub fn bright_cyan(&mut self) -> &mut Self

Apply the foreground color bright cyan value to the escape sequence.

Source

pub fn bright_white(&mut self) -> &mut Self

Apply the foreground color bright white value to the escape sequence.

Source

pub fn bg_black(&mut self) -> &mut Self

Apply the background color black value to the escape sequence.

Source

pub fn bg_red(&mut self) -> &mut Self

Apply the background color red value to the escape sequence.

Source

pub fn bg_green(&mut self) -> &mut Self

Apply the background color green value to the escape sequence.

Source

pub fn bg_yellow(&mut self) -> &mut Self

Apply the background color yellow value to the escape sequence.

Source

pub fn bg_blue(&mut self) -> &mut Self

Apply the background color blue value to the escape sequence.

Source

pub fn bg_magenta(&mut self) -> &mut Self

Apply the background color magenta value to the escape sequence.

Source

pub fn bg_cyan(&mut self) -> &mut Self

Apply the background color cyan value to the escape sequence.

Source

pub fn bg_white(&mut self) -> &mut Self

Apply the background color white value to the escape sequence.

Source

pub fn bg_gray(&mut self) -> &mut Self

Apply the background color gray value to the escape sequence.

Source

pub fn bg_bright_red(&mut self) -> &mut Self

Apply the background color bright red value to the escape sequence.

Source

pub fn bg_bright_green(&mut self) -> &mut Self

Apply the background color bright green value to the escape sequence.

Source

pub fn bg_bright_yellow(&mut self) -> &mut Self

Apply the background color bright yellow value to the escape sequence.

Source

pub fn bg_bright_blue(&mut self) -> &mut Self

Apply the background color bright blue value to the escape sequence.

Source

pub fn bg_bright_magenta(&mut self) -> &mut Self

Apply the background color bright magenta value to the escape sequence.

Source

pub fn bg_bright_cyan(&mut self) -> &mut Self

Apply the background color bright cyan value to the escape sequence.

Source

pub fn bg_bright_white(&mut self) -> &mut Self

Apply the background color bright white value to the escape sequence.

Trait Implementations§

Source§

impl Display for Style

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Style

§

impl RefUnwindSafe for Style

§

impl Send for Style

§

impl Sync for Style

§

impl Unpin for Style

§

impl UnwindSafe for Style

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.