pub struct Printer { /* private fields */ }Expand description
A printer that can toggle color output on or off
Implementations§
Source§impl Printer
impl Printer
Sourcepub const fn without_color() -> Self
pub const fn without_color() -> Self
Create a printer with colors disabled
Sourcepub fn auto_detect() -> Self
pub fn auto_detect() -> Self
Create a printer with color detection based on TTY
Sourcepub fn enable_color(&mut self)
pub fn enable_color(&mut self)
Enable colors
Sourcepub fn disable_color(&mut self)
pub fn disable_color(&mut self)
Disable colors
Sourcepub const fn colors_enabled(&self) -> bool
pub const fn colors_enabled(&self) -> bool
Check if colors are enabled
Sourcepub fn print<W: Write, T: Display>(
&self,
writer: &mut W,
style: Style,
value: T,
) -> Result<()>
pub fn print<W: Write, T: Display>( &self, writer: &mut W, style: Style, value: T, ) -> Result<()>
Print styled text, respecting the color setting
Sourcepub fn println<W: Write, T: Display>(
&self,
writer: &mut W,
style: Style,
value: T,
) -> Result<()>
pub fn println<W: Write, T: Display>( &self, writer: &mut W, style: Style, value: T, ) -> Result<()>
Print styled text with newline, respecting the color setting
Sourcepub fn styled<T: Display>(&self, style: Style, value: T) -> PrinterStyledText<T>
pub fn styled<T: Display>(&self, style: Style, value: T) -> PrinterStyledText<T>
Create a styled text that respects this printer’s color setting
Sourcepub fn color<T: Display>(&self, color: Color, value: T) -> PrinterStyledText<T>
pub fn color<T: Display>(&self, color: Color, value: T) -> PrinterStyledText<T>
Convenience method for colored text
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Printer
impl RefUnwindSafe for Printer
impl Send for Printer
impl Sync for Printer
impl Unpin for Printer
impl UnwindSafe for Printer
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