Struct console::Style

source ·
pub struct Style { /* private fields */ }
Expand description

A stored style that can be applied.

Implementations§

source§

impl Style

source

pub fn new() -> Style

Returns an empty default style.

source

pub fn from_dotted_str(s: &str) -> Style

Creates a style from a dotted string.

Effectively the string is split at each dot and then the terms in between are applied. For instance red.on_blue will create a string that is red on blue background. 9.on_12 is the same, but using 256 color numbers. Unknown terms are ignored.

source

pub fn apply_to<D>(&self, val: D) -> StyledObject<D>

Apply the style to something that can be displayed.

source

pub fn force_styling(self, value: bool) -> Style

Forces styling on or off.

This overrides the automatic detection.

source

pub fn for_stderr(self) -> Style

Specifies that style is applying to something being written on stderr.

source

pub fn for_stdout(self) -> Style

Specifies that style is applying to something being written on stdout.

This is the default behaviour.

source

pub fn fg(self, color: Color) -> Style

Sets a foreground color.

source

pub fn bg(self, color: Color) -> Style

Sets a background color.

source

pub fn attr(self, attr: Attribute) -> Style

Adds a attr.

source

pub fn black(self) -> Style

source

pub fn red(self) -> Style

source

pub fn green(self) -> Style

source

pub fn yellow(self) -> Style

source

pub fn blue(self) -> Style

source

pub fn magenta(self) -> Style

source

pub fn cyan(self) -> Style

source

pub fn white(self) -> Style

source

pub fn color256(self, color: u8) -> Style

source

pub fn bright(self) -> Style

source

pub fn on_black(self) -> Style

source

pub fn on_red(self) -> Style

source

pub fn on_green(self) -> Style

source

pub fn on_yellow(self) -> Style

source

pub fn on_blue(self) -> Style

source

pub fn on_magenta(self) -> Style

source

pub fn on_cyan(self) -> Style

source

pub fn on_white(self) -> Style

source

pub fn on_color256(self, color: u8) -> Style

source

pub fn on_bright(self) -> Style

source

pub fn bold(self) -> Style

source

pub fn dim(self) -> Style

source

pub fn italic(self) -> Style

source

pub fn underlined(self) -> Style

source

pub fn reverse(self) -> Style

source

pub fn hidden(self) -> Style

source

pub fn strikethrough(self) -> Style

Trait Implementations§

source§

impl Clone for Style

source§

fn clone(&self) -> Style

Returns a copy 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 Style

source§

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

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

impl Default for Style

source§

fn default() -> Style

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

impl PartialEq for Style

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Style

source§

impl StructuralEq for Style

source§

impl StructuralPartialEq for Style

Auto Trait Implementations§

§

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

§

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>,

§

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>,

§

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.