AnsiStyle

Struct AnsiStyle 

Source
pub struct AnsiStyle {
    pub fg_color: Option<AnsiColor>,
    pub bg_color: Option<AnsiColor>,
    pub bold: bool,
    pub intense: bool,
    pub underline: bool,
    pub dimmed: bool,
    pub italic: bool,
    pub reset: bool,
    pub strikethrough: bool,
}
Expand description

The definition of the ANSI styles.

Fields§

§fg_color: Option<AnsiColor>

The foreground color.

§bg_color: Option<AnsiColor>

The background color.

§bold: bool

Get whether this is bold or not.

§intense: bool

Get whether this is intense or not.

On Unix-like systems, this will output the ANSI escape sequence that will print a high-intensity version of the color specified.

On Windows systems, this will output the ANSI escape sequence that will print a brighter version of the color specified.

§underline: bool

Get whether this is underlined or not.

§dimmed: bool

Get whether this is dimmed or not.

Note that the dimmed setting has no effect in a Windows console.

§italic: bool

Get whether this is italic or not.

Note that the italic setting has no effect in a Windows console.

§reset: bool

Get whether reset is enabled or not.

reset is enabled by default. When disabled and using ANSI escape sequences, a “reset” code will be emitted every time a ColorSpec’s settings are applied.

Note that the reset setting has no effect in a Windows console.

§strikethrough: bool

Get whether this is strikethrough or not.

Note that the strikethrough setting has no effect in a Windows console.

Implementations§

Source§

impl AnsiStyle

Source

pub fn new(foreground: AnsiColor) -> AnsiStyle

Create a new ColorSpec with the foreground color specified.

Source

pub fn rgb(r: u8, g: u8, b: u8) -> AnsiStyle

Create a new ColorSpec with the foreground color specified.

Source

pub fn with_fg_color(self, color: AnsiColor) -> AnsiStyle

Create a new ColorSpec with the foreground color specified.

Source

pub fn with_bg_color(self, color: AnsiColor) -> AnsiStyle

Create a new ColorSpec with the background color specified.

Source

pub fn with_underline(self) -> AnsiStyle

Create a new AnsiStyle with underline enabled.

Source

pub fn with_bold(self) -> AnsiStyle

Create a new AnsiStyle with dimmed enabled.

Source

pub fn with_italic(self) -> AnsiStyle

Create a new AnsiStyle with dimmed enabled.

Trait Implementations§

Source§

impl Clone for AnsiStyle

Source§

fn clone(&self) -> AnsiStyle

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AnsiStyle

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for AnsiStyle

Source§

fn default() -> AnsiStyle

Returns the “default value” for a type. Read more
Source§

impl PartialEq for AnsiStyle

Source§

fn eq(&self, other: &AnsiStyle) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for AnsiStyle

Source§

impl Eq for AnsiStyle

Source§

impl StructuralPartialEq for AnsiStyle

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.