pub struct StyledContent<D: Display> { /* private fields */ }
Expand description

The style with the content to be styled.

Examples

use crossterm::style::{style, Color, Attribute, Stylize};

let styled = "Hello there"
    .with(Color::Yellow)
    .on(Color::Blue)
    .attribute(Attribute::Bold);

println!("{}", styled);

Implementations§

source§

impl<D: Display> StyledContent<D>

source

pub fn new(style: ContentStyle, content: D) -> StyledContent<D>

Creates a new StyledContent.

source

pub fn content(&self) -> &D

Returns the content.

source

pub fn style(&self) -> &ContentStyle

Returns the style.

source

pub fn style_mut(&mut self) -> &mut ContentStyle

Returns a mutable reference to the style, so that it can be further manipulated

Trait Implementations§

source§

impl<D: Display> AsMut<ContentStyle> for StyledContent<D>

source§

fn as_mut(&mut self) -> &mut ContentStyle

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl<D: Display> AsRef<ContentStyle> for StyledContent<D>

source§

fn as_ref(&self) -> &ContentStyle

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<D: Clone + Display> Clone for StyledContent<D>

source§

fn clone(&self) -> StyledContent<D>

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<D: Debug + Display> Debug for StyledContent<D>

source§

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

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

impl<D: Display> Display for StyledContent<D>

source§

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

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

impl<D: PartialEq + Display> PartialEq<StyledContent<D>> for StyledContent<D>

source§

fn eq(&self, other: &StyledContent<D>) -> 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<D: Display> Stylize for StyledContent<D>

§

type Styled = StyledContent<D>

This type with styles applied.
source§

fn stylize(self) -> Self::Styled

Styles this type.
source§

fn with(self, color: Color) -> Self::Styled

Sets the foreground color.
source§

fn on(self, color: Color) -> Self::Styled

Sets the background color.
source§

fn underline(self, color: Color) -> Self::Styled

Sets the underline color.
source§

fn attribute(self, attr: Attribute) -> Self::Styled

Styles the content with the attribute.
source§

fn reset(self) -> Self::Styled

Applies the Reset attribute to the text.
source§

fn bold(self) -> Self::Styled

Applies the Bold attribute to the text.
source§

fn underlined(self) -> Self::Styled

Applies the Underlined attribute to the text.
source§

fn reverse(self) -> Self::Styled

Applies the Reverse attribute to the text.
source§

fn dim(self) -> Self::Styled

Applies the Dim attribute to the text.
source§

fn italic(self) -> Self::Styled

Applies the Italic attribute to the text.
source§

fn negative(self) -> Self::Styled

Applies the Reverse attribute to the text.
Applies the SlowBlink attribute to the text.
Applies the RapidBlink attribute to the text.
source§

fn hidden(self) -> Self::Styled

Applies the Hidden attribute to the text.
source§

fn crossed_out(self) -> Self::Styled

Applies the CrossedOut attribute to the text.
source§

fn black(self) -> Self::Styled

Sets the foreground color to Black.
source§

fn on_black(self) -> Self::Styled

Sets the background color to Black.
source§

fn underline_black(self) -> Self::Styled

Sets the underline color to Black.
source§

fn dark_grey(self) -> Self::Styled

Sets the foreground color to DarkGrey.
source§

fn on_dark_grey(self) -> Self::Styled

Sets the background color to DarkGrey.
source§

fn underline_dark_grey(self) -> Self::Styled

Sets the underline color to DarkGrey.
source§

fn red(self) -> Self::Styled

Sets the foreground color to Red.
source§

fn on_red(self) -> Self::Styled

Sets the background color to Red.
source§

fn underline_red(self) -> Self::Styled

Sets the underline color to Red.
source§

fn dark_red(self) -> Self::Styled

Sets the foreground color to DarkRed.
source§

fn on_dark_red(self) -> Self::Styled

Sets the background color to DarkRed.
source§

fn underline_dark_red(self) -> Self::Styled

Sets the underline color to DarkRed.
source§

fn green(self) -> Self::Styled

Sets the foreground color to Green.
source§

fn on_green(self) -> Self::Styled

Sets the background color to Green.
source§

fn underline_green(self) -> Self::Styled

Sets the underline color to Green.
source§

fn dark_green(self) -> Self::Styled

Sets the foreground color to DarkGreen.
source§

fn on_dark_green(self) -> Self::Styled

Sets the background color to DarkGreen.
source§

fn underline_dark_green(self) -> Self::Styled

Sets the underline color to DarkGreen.
source§

fn yellow(self) -> Self::Styled

Sets the foreground color to Yellow.
source§

fn on_yellow(self) -> Self::Styled

Sets the background color to Yellow.
source§

fn underline_yellow(self) -> Self::Styled

Sets the underline color to Yellow.
source§

fn dark_yellow(self) -> Self::Styled

Sets the foreground color to DarkYellow.
source§

fn on_dark_yellow(self) -> Self::Styled

Sets the background color to DarkYellow.
source§

fn underline_dark_yellow(self) -> Self::Styled

Sets the underline color to DarkYellow.
source§

fn blue(self) -> Self::Styled

Sets the foreground color to Blue.
source§

fn on_blue(self) -> Self::Styled

Sets the background color to Blue.
source§

fn underline_blue(self) -> Self::Styled

Sets the underline color to Blue.
source§

fn dark_blue(self) -> Self::Styled

Sets the foreground color to DarkBlue.
source§

fn on_dark_blue(self) -> Self::Styled

Sets the background color to DarkBlue.
source§

fn underline_dark_blue(self) -> Self::Styled

Sets the underline color to DarkBlue.
source§

fn magenta(self) -> Self::Styled

Sets the foreground color to Magenta.
source§

fn on_magenta(self) -> Self::Styled

Sets the background color to Magenta.
source§

fn underline_magenta(self) -> Self::Styled

Sets the underline color to Magenta.
source§

fn dark_magenta(self) -> Self::Styled

Sets the foreground color to DarkMagenta.
source§

fn on_dark_magenta(self) -> Self::Styled

Sets the background color to DarkMagenta.
source§

fn underline_dark_magenta(self) -> Self::Styled

Sets the underline color to DarkMagenta.
source§

fn cyan(self) -> Self::Styled

Sets the foreground color to Cyan.
source§

fn on_cyan(self) -> Self::Styled

Sets the background color to Cyan.
source§

fn underline_cyan(self) -> Self::Styled

Sets the underline color to Cyan.
source§

fn dark_cyan(self) -> Self::Styled

Sets the foreground color to DarkCyan.
source§

fn on_dark_cyan(self) -> Self::Styled

Sets the background color to DarkCyan.
source§

fn underline_dark_cyan(self) -> Self::Styled

Sets the underline color to DarkCyan.
source§

fn white(self) -> Self::Styled

Sets the foreground color to White.
source§

fn on_white(self) -> Self::Styled

Sets the background color to White.
source§

fn underline_white(self) -> Self::Styled

Sets the underline color to White.
source§

fn grey(self) -> Self::Styled

Sets the foreground color to Grey.
source§

fn on_grey(self) -> Self::Styled

Sets the background color to Grey.
source§

fn underline_grey(self) -> Self::Styled

Sets the underline color to Grey.
source§

impl<D: Copy + Display> Copy for StyledContent<D>

source§

impl<D: Eq + Display> Eq for StyledContent<D>

source§

impl<D: Display> StructuralEq for StyledContent<D>

source§

impl<D: Display> StructuralPartialEq for StyledContent<D>

Auto Trait Implementations§

§

impl<D> RefUnwindSafe for StyledContent<D>where D: RefUnwindSafe,

§

impl<D> Send for StyledContent<D>where D: Send,

§

impl<D> Sync for StyledContent<D>where D: Sync,

§

impl<D> Unpin for StyledContent<D>where D: Unpin,

§

impl<D> UnwindSafe for StyledContent<D>where D: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

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

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.