ANSIString

Struct ANSIString 

Source
pub struct ANSIString<T> { /* private fields */ }
Expand description

A struct that owns T, also holds ANSI styles and colors

Implementations§

Source§

impl<T> ANSIString<T>

Source

pub fn clear(self) -> T

Returns ownership of T, while consuming self

Source

pub fn to_string(self) -> String
where T: AsRef<str>,

to_string method implemented directly on struct for performance reasons

Source

pub fn is_foreground_colored(&self) -> bool

Returns true if foreground (letters) of a string is colored

Source

pub fn is_background_colored(&self) -> bool

Return true if background (bounding box) of a string is colored

Source

pub fn is_colored(&self) -> bool

Returns true if both background and foreground of a string is colored

Source

pub fn is_styled(&self) -> bool

Return true if string is styled, e.g. bold or italic

Trait Implementations§

Source§

impl<T: Clone> Clone for ANSIString<T>

Source§

fn clone(&self) -> ANSIString<T>

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<T> Colored for &mut ANSIString<T>

Source§

type Output = ()

This is returned by all methods
Source§

fn blue(self) -> Self::Output

Colors foreground of a string in blue Read more
Source§

fn on_blue(self) -> Self::Output

Colors background of a string in blue Read more
Source§

fn cyan(self) -> Self::Output

Colors foreground of a string in cyan Read more
Source§

fn on_cyan(self) -> Self::Output

Colors background of a string in cyan Read more
Source§

fn green(self) -> Self::Output

Colors foreground of a string in green Read more
Source§

fn on_green(self) -> Self::Output

Colors background of a string in green Read more
Source§

fn magenta(self) -> Self::Output

Colors foreground of a string in magenta Read more
Source§

fn on_magenta(self) -> Self::Output

Colors background of a string in magenta Read more
Source§

fn orange(self) -> Self::Output

Colors foreground of a string in orange Read more
Source§

fn on_orange(self) -> Self::Output

Colors background of a string in orange Read more
Source§

fn red(self) -> Self::Output

Colors foreground of a string in red Read more
Source§

fn on_red(self) -> Self::Output

Colors background of a string in red Read more
Source§

fn yellow(self) -> Self::Output

Colors foreground of a string in yellow Read more
Source§

fn on_yellow(self) -> Self::Output

Colors background of a string in yellow Read more
Source§

fn rgb(self, r: u8, g: u8, b: u8) -> Self::Output

Colors foreground of a string in rgb Read more
Source§

fn on_rgb(self, r: u8, g: u8, b: u8) -> Self::Output

Colors background of a string in rgb Read more
Source§

impl<T> Colored for ANSIString<T>

Source§

type Output = ANSIString<T>

This is returned by all methods
Source§

fn blue(self) -> Self::Output

Colors foreground of a string in blue Read more
Source§

fn on_blue(self) -> Self::Output

Colors background of a string in blue Read more
Source§

fn cyan(self) -> Self::Output

Colors foreground of a string in cyan Read more
Source§

fn on_cyan(self) -> Self::Output

Colors background of a string in cyan Read more
Source§

fn green(self) -> Self::Output

Colors foreground of a string in green Read more
Source§

fn on_green(self) -> Self::Output

Colors background of a string in green Read more
Source§

fn magenta(self) -> Self::Output

Colors foreground of a string in magenta Read more
Source§

fn on_magenta(self) -> Self::Output

Colors background of a string in magenta Read more
Source§

fn orange(self) -> Self::Output

Colors foreground of a string in orange Read more
Source§

fn on_orange(self) -> Self::Output

Colors background of a string in orange Read more
Source§

fn red(self) -> Self::Output

Colors foreground of a string in red Read more
Source§

fn on_red(self) -> Self::Output

Colors background of a string in red Read more
Source§

fn yellow(self) -> Self::Output

Colors foreground of a string in yellow Read more
Source§

fn on_yellow(self) -> Self::Output

Colors background of a string in yellow Read more
Source§

fn rgb(self, r: u8, g: u8, b: u8) -> Self::Output

Colors foreground of a string in rgb Read more
Source§

fn on_rgb(self, r: u8, g: u8, b: u8) -> Self::Output

Colors background of a string in rgb Read more
Source§

impl<T: Debug> Debug for ANSIString<T>

Source§

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

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

impl<T: AsRef<str>> Display for ANSIString<T>

Source§

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

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

impl<T: AsRef<str>> From<ANSIString<T>> for String

Source§

fn from(value: ANSIString<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: PartialEq> PartialEq for ANSIString<T>

Source§

fn eq(&self, other: &ANSIString<T>) -> 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<T> Styled for &mut ANSIString<T>

Source§

type Output = ()

This is returned by all methods
Source§

fn bold(self) -> Self::Output

Causes a string to be displayed as bold Read more
Source§

fn dim(self) -> Self::Output

Causes a string to appear darker (not widely supported) Read more
Source§

fn italic(self) -> Self::Output

Causes a string to be displayed as italic Read more
Source§

fn underline(self) -> Self::Output

Causes a string to be displayed as underlined Read more
Causes a string to blink (not widely supported) Read more
Source§

fn invert(self) -> Self::Output

Inverts colors of a string (not widely supported) Read more
Source§

fn hide(self) -> Self::Output

Hides a string (not widely supported) Read more
Source§

fn strikethrough(self) -> Self::Output

Causes a string to be displayed as striked out Read more
Source§

impl<T> Styled for ANSIString<T>

Source§

type Output = ANSIString<T>

This is returned by all methods
Source§

fn bold(self) -> Self::Output

Causes a string to be displayed as bold Read more
Source§

fn dim(self) -> Self::Output

Causes a string to appear darker (not widely supported) Read more
Source§

fn italic(self) -> Self::Output

Causes a string to be displayed as italic Read more
Source§

fn underline(self) -> Self::Output

Causes a string to be displayed as underlined Read more
Causes a string to blink (not widely supported) Read more
Source§

fn invert(self) -> Self::Output

Inverts colors of a string (not widely supported) Read more
Source§

fn hide(self) -> Self::Output

Hides a string (not widely supported) Read more
Source§

fn strikethrough(self) -> Self::Output

Causes a string to be displayed as striked out Read more
Source§

impl<T> StructuralPartialEq for ANSIString<T>

Auto Trait Implementations§

§

impl<T> Freeze for ANSIString<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for ANSIString<T>
where T: RefUnwindSafe,

§

impl<T> Send for ANSIString<T>
where T: Send,

§

impl<T> Sync for ANSIString<T>
where T: Sync,

§

impl<T> Unpin for ANSIString<T>
where T: Unpin,

§

impl<T> UnwindSafe for ANSIString<T>
where T: UnwindSafe,

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