pub struct OutputWriter { /* private fields */ }
Expand description
Writer for printing to stdout and stderr
Printing in handlers should be done through OutputWriter
,
which automatically uses the configured out and err colors.
It also records output in commands so that it can be collected into CmdOutput
fn hello(mut out: StateMut<OutputWriter>) -> anyhow::Result<()> {
out.println("Hello")?;
Ok(())
}
Implementations§
Source§impl OutputWriter
impl OutputWriter
pub fn new(out_style: ContentStyle, err_style: ContentStyle) -> OutputWriter
Sourcepub fn eprint<T>(&mut self, s: T) -> Result<(), Error>where
T: Display,
pub fn eprint<T>(&mut self, s: T) -> Result<(), Error>where
T: Display,
Prints to stderr and appends a newline character
Sourcepub fn eprintln<T>(&mut self, s: T) -> Result<(), Error>where
T: Display,
pub fn eprintln<T>(&mut self, s: T) -> Result<(), Error>where
T: Display,
Calls eprint, then prints a newline
Sourcepub fn print<T>(&mut self, s: T) -> Result<(), Error>where
T: Display,
pub fn print<T>(&mut self, s: T) -> Result<(), Error>where
T: Display,
Prints to stdout using out_style for styling.
Trait Implementations§
Source§impl Default for OutputWriter
impl Default for OutputWriter
Source§fn default() -> OutputWriter
fn default() -> OutputWriter
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for OutputWriter
impl RefUnwindSafe for OutputWriter
impl Send for OutputWriter
impl Sync for OutputWriter
impl Unpin for OutputWriter
impl UnwindSafe for OutputWriter
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