pub struct Paint<T> {
pub item: T,
pub style: Style,
}Expand description
A structure encapsulating an item and styling.
Fields§
§item: T§style: StyleImplementations§
Source§impl<T> Paint<T>
impl<T> Paint<T>
Sourcepub const fn new(item: T) -> Paint<T>
pub const fn new(item: T) -> Paint<T>
Constructs a new Paint structure encapsulating item with no set
styling.
Sourcepub const fn wrapping(item: T) -> Paint<T>
pub const fn wrapping(item: T) -> Paint<T>
Constructs a new wrapping Paint structure encapsulating item with
default styling.
A wrapping Paint converts all color resets written out by the internal
value to the styling of itself. This allows for seamless color wrapping
of other colored text.
§Performance
In order to wrap an internal value, the internal value must first be written out to a local buffer and examined. As a result, displaying a wrapped value is likely to result in a heap allocation and copy.
Sourcepub const fn rgb(r: u8, g: u8, b: u8, item: T) -> Paint<T>
pub const fn rgb(r: u8, g: u8, b: u8, item: T) -> Paint<T>
Constructs a new Paint structure encapsulating item with the
foreground color set to the RGB color r, g, b.
Sourcepub const fn fixed(color: u8, item: T) -> Paint<T>
pub const fn fixed(color: u8, item: T) -> Paint<T>
Constructs a new Paint structure encapsulating item with the
foreground color set to the fixed 8-bit color color.
pub const fn red(item: T) -> Paint<T>
pub const fn black(item: T) -> Paint<T>
pub const fn yellow(item: T) -> Paint<T>
pub const fn green(item: T) -> Paint<T>
pub const fn cyan(item: T) -> Paint<T>
pub const fn blue(item: T) -> Paint<T>
pub const fn magenta(item: T) -> Paint<T>
pub const fn white(item: T) -> Paint<T>
Sourcepub fn with_style(self, style: Style) -> Paint<T>
pub fn with_style(self, style: Style) -> Paint<T>
Sets the style of self to style.
Sourcepub const fn wrap(self) -> Paint<T>
pub const fn wrap(self) -> Paint<T>
Makes self a wrapping Paint.
A wrapping Paint converts all color resets written out by the internal
value to the styling of itself. This allows for seamless color wrapping
of other colored text.
§Performance
In order to wrap an internal value, the internal value must first be written out to a local buffer and examined. As a result, displaying a wrapped value is likely to result in a heap allocation and copy.
pub fn bold(self) -> Paint<T>
pub fn dim(self) -> Paint<T>
pub fn italic(self) -> Paint<T>
pub fn underline(self) -> Paint<T>
pub fn invert(self) -> Paint<T>
pub fn strikethrough(self) -> Paint<T>
pub fn blink(self) -> Paint<T>
Source§impl Paint<()>
impl Paint<()>
Sourcepub fn is_enabled() -> bool
pub fn is_enabled() -> bool
Returns true if coloring is enabled and false otherwise.
Sourcepub fn set_terminal(tf: TerminalFile)
pub fn set_terminal(tf: TerminalFile)
Set the terminal we are writing to. This influences the logic that checks whether or not to include colors.
Trait Implementations§
Source§impl Cell for Paint<&str>
impl Cell for Paint<&str>
Source§impl Cell for Paint<String>
impl Cell for Paint<String>
Source§impl<T> Ord for Paint<T>where
T: Ord,
impl<T> Ord for Paint<T>where
T: Ord,
Source§impl<T> PartialOrd for Paint<T>where
T: PartialOrd,
impl<T> PartialOrd for Paint<T>where
T: PartialOrd,
impl<T> Copy for Paint<T>where
T: Copy,
impl<T> Eq for Paint<T>where
T: Eq,
impl<T> StructuralPartialEq for Paint<T>
Auto Trait Implementations§
impl<T> Freeze for Paint<T>where
T: Freeze,
impl<T> RefUnwindSafe for Paint<T>where
T: RefUnwindSafe,
impl<T> Send for Paint<T>where
T: Send,
impl<T> Sync for Paint<T>where
T: Sync,
impl<T> Unpin for Paint<T>where
T: Unpin,
impl<T> UnwindSafe for Paint<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more