pub struct ColorAccumulator { /* private fields */ }
Expand description
A facility for creating visually inspectable representations of colored output so they can be easily tested.
A new color is represented as {style}
and a reset is represented by {/}
.
Attributes are printed in this order:
- Foreground color as
fg:Color
- Background color as
bg:Color
- Bold as
bold
- Underline as
underline
- Intense as
bright
For example, the style “intense, bold red foreground” would be printed as:
{fg:Red bold intense}
Since this implementation attempts to make it possible to faithfully understand what real WriteColor implementations would do, it tries to approximate the contract in the WriteColor trait: “Subsequent writes to this write will use these settings until either reset is called or new color settings are set.”)
- If set_color is called with a style,
{...}
is emitted containing the color attributes. - If set_color is called with no style,
{/}
is emitted - If reset is called,
{/}
is emitted
Implementations§
Trait Implementations§
Source§impl Write for ColorAccumulator
impl Write for ColorAccumulator
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Writes a buffer into this writer, returning how many bytes were written. Read more
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Flushes this output stream, ensuring that all intermediately buffered
contents reach their destination. Read more
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector
)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Attempts to write an entire buffer into this writer. Read more
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
write_all_vectored
)Attempts to write multiple buffers into this writer. Read more
Source§impl WriteColor for ColorAccumulator
impl WriteColor for ColorAccumulator
Source§fn supports_color(&self) -> bool
fn supports_color(&self) -> bool
Returns true if and only if the underlying writer supports colors.
Source§fn set_color(&mut self, spec: &ColorSpec) -> Result<()>
fn set_color(&mut self, spec: &ColorSpec) -> Result<()>
Set the color settings of the writer. Read more
Source§fn reset(&mut self) -> Result<()>
fn reset(&mut self) -> Result<()>
Reset the current color settings to their original settings. Read more
Source§fn is_synchronous(&self) -> bool
fn is_synchronous(&self) -> bool
Returns true if and only if the underlying writer must synchronously
interact with an end user’s device in order to control colors. By
default, this always returns
false
. Read moreSource§fn set_hyperlink(&mut self, _link: &HyperlinkSpec<'_>) -> Result<(), Error>
fn set_hyperlink(&mut self, _link: &HyperlinkSpec<'_>) -> Result<(), Error>
Set the current hyperlink of the writer. Read more
Source§fn supports_hyperlinks(&self) -> bool
fn supports_hyperlinks(&self) -> bool
Returns true if and only if the underlying writer supports hyperlinks. Read more
Auto Trait Implementations§
impl Freeze for ColorAccumulator
impl RefUnwindSafe for ColorAccumulator
impl Send for ColorAccumulator
impl Sync for ColorAccumulator
impl Unpin for ColorAccumulator
impl UnwindSafe for ColorAccumulator
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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