pub enum OutputWriter {
Csv(BufWriter<File>),
Stdout,
}Expand description
Output writer for metrics snapshots.
Supports CSV file and stdout output modes.
§Example
use lightbench::output::OutputWriter;
use lightbench::metrics::Stats;
let stats = Stats::new();
// CSV output
let mut writer = OutputWriter::new_csv("results.csv".into()).await.unwrap();
// Or stdout
let mut stdout_writer = OutputWriter::new_stdout();
let snapshot = stats.snapshot().await;
writer.write_snapshot(&snapshot).await.unwrap();Variants§
Implementations§
Source§impl OutputWriter
impl OutputWriter
Sourcepub async fn new_csv(path: String) -> Result<Self, FrameworkError>
pub async fn new_csv(path: String) -> Result<Self, FrameworkError>
Create a new CSV file writer.
Creates parent directories if needed and writes the CSV header.
Sourcepub fn new_stdout() -> Self
pub fn new_stdout() -> Self
Create a stdout writer.
Sourcepub async fn write_snapshot(
&mut self,
snapshot: &StatsSnapshot,
) -> Result<(), FrameworkError>
pub async fn write_snapshot( &mut self, snapshot: &StatsSnapshot, ) -> Result<(), FrameworkError>
Write a statistics snapshot.
For CSV mode, flushes after each write for tail-readable output.
Sourcepub async fn flush(&mut self) -> Result<(), FrameworkError>
pub async fn flush(&mut self) -> Result<(), FrameworkError>
Flush any buffered output.
Auto Trait Implementations§
impl !Freeze for OutputWriter
impl !RefUnwindSafe for OutputWriter
impl Send for OutputWriter
impl Sync for OutputWriter
impl Unpin for OutputWriter
impl UnsafeUnpin 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