Struct StyledText

Source
pub struct StyledText<'a> { /* private fields */ }
Expand description

Represents a piece of text with optional color and formatting.

Implementations§

Source§

impl<'a> StyledText<'a>

Source

pub fn new(text: &'a str) -> Self

Creates a new StyledText instance with default settings.

§Arguments
  • text - The string slice representing the text.
§Returns

A StyledText instance with no colors or formatting applied.

Source

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

Sets the foreground color of the text.

§Arguments
  • color - A Color enum variant representing the desired foreground color.
§Returns

The modified StyledText instance.

Source

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

Sets the background color of the text.

§Arguments
  • color - A Color enum variant representing the desired background color.
§Returns

The modified StyledText instance.

Source

pub fn bold(self) -> Self

Enables bold formatting for the text.

§Returns

The modified StyledText instance with bold formatting applied.

Source

pub fn italic(self) -> Self

Enables italic formatting for the text.

§Returns

The modified StyledText instance with italic formatting applied.

Source

pub fn underline(self) -> Self

Enables underline formatting for the text.

§Returns

The modified StyledText instance with underline formatting applied.

Enables blink effect for the text.

§Returns

The modified StyledText instance with blinking enabled.

Source

pub fn reverse(self) -> Self

Enables reverse video (inverts foreground and background colors).

§Returns

The modified StyledText instance with inverted colors.

Source

pub fn strikethrough(self) -> Self

Enables strikethrough formatting for the text.

§Returns

The modified StyledText instance with strikethrough applied.

Source

pub fn format_sequence(&'a self) -> String

Converts the colored text into a formatted ANSI escape sequence string.

§Returns

A String containing the ANSI-formatted text.

Trait Implementations§

Source§

impl Display for StyledText<'_>

Implements the Display trait for StyledText, allowing it to be printed directly.

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for StyledText<'a>

§

impl<'a> RefUnwindSafe for StyledText<'a>

§

impl<'a> Send for StyledText<'a>

§

impl<'a> Sync for StyledText<'a>

§

impl<'a> Unpin for StyledText<'a>

§

impl<'a> UnwindSafe for StyledText<'a>

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.