pub struct StatsWriter<W: Write> { /* private fields */ }Expand description
Streams a stat time series to a writer as CSV.
Call push once per sampled tick, then finish. The first push
writes the header, with the columns of its sample. A StatDescriptor
does not say whether its value is a scalar, a vector or a histogram.
Implementations§
Source§impl<W: Write> StatsWriter<W>
impl<W: Write> StatsWriter<W>
Sourcepub fn push(
&mut self,
tick: u64,
stats: &[StatEntry],
) -> Result<(), StatsWriteError>
pub fn push( &mut self, tick: u64, stats: &[StatEntry], ) -> Result<(), StatsWriteError>
Writes the row of the sample stats, taken at tick.
The first call fixes the column layout and writes the header.
§Errors
Returns StatsWriteError::Io when a write fails, and StatsWriteError::Shape when stats does not fit
the layout the first sample fixed.
Sourcepub fn finish(self) -> Result<u64, StatsWriteError>
pub fn finish(self) -> Result<u64, StatsWriteError>
Flushes the writer and returns the number of rows written.
Note that a BufWriter dropped without a flush discards its write errors.
§Errors
Returns StatsWriteError::Io when the flush fails.
Sourcepub fn into_inner(self) -> Result<(W, u64), StatsWriteError>
pub fn into_inner(self) -> Result<(W, u64), StatsWriteError>
Flushes the writer and returns it with the number of rows written.
§Errors
Returns StatsWriteError::Io when the flush fails.