pub struct Output { /* private fields */ }Expand description
Structured output writer — all terminal I/O goes through this.
Provides plain output methods (line, blank, raw), styled convenience
methods (success, error, warning, info, dim, bold), and
implements Write so the standard write!/writeln! macros work
directly with ANSI style constants.
§Examples
use tinyharness_ui::output::Output;
use std::io::Write;
let mut out = Output::stdout();
let _ = writeln!(out, "Hello, world!");
out.success("Done.").unwrap();Implementations§
Source§impl Output
impl Output
Sourcepub fn new(writer: Box<dyn Write + Send>) -> Self
pub fn new(writer: Box<dyn Write + Send>) -> Self
Create an Output with a custom writer (e.g. a Vec<u8> for testing).
Sourcepub fn line(&mut self, text: &str) -> Result<()>
pub fn line(&mut self, text: &str) -> Result<()>
Write text followed by a newline.
Returns io::Result<()>; callers may use let _ = out.line("...");
to ignore errors when writing to stdout/stderr (where failures are rare
and typically fatal anyway).
Sourcepub fn raw(&mut self, bytes: &[u8]) -> Result<()>
pub fn raw(&mut self, bytes: &[u8]) -> Result<()>
Write raw bytes as-is (no newline appended, no styling applied).
Sourcepub fn success(&mut self, msg: &str) -> Result<()>
pub fn success(&mut self, msg: &str) -> Result<()>
Write a success message (green) followed by a newline.
Sourcepub fn error(&mut self, msg: &str) -> Result<()>
pub fn error(&mut self, msg: &str) -> Result<()>
Write an error message (red) followed by a newline.
Sourcepub fn warning(&mut self, msg: &str) -> Result<()>
pub fn warning(&mut self, msg: &str) -> Result<()>
Write a warning message (orange) followed by a newline.
Trait Implementations§
Source§impl Write for Output
impl Write for Output
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored)