Skip to main content

StatsWriter

Struct StatsWriter 

Source
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>

Source

pub fn new(out: W) -> Self

Returns a writer over out that has written nothing.

Source

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.

Source

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.

Source

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.

Source

pub fn rows(&self) -> u64

Number of rows written so far, not counting the header.

Trait Implementations§

Source§

impl<W: Debug + Write> Debug for StatsWriter<W>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<W> Freeze for StatsWriter<W>
where W: Freeze,

§

impl<W> RefUnwindSafe for StatsWriter<W>
where W: RefUnwindSafe,

§

impl<W> Send for StatsWriter<W>
where W: Send,

§

impl<W> Sync for StatsWriter<W>
where W: Sync,

§

impl<W> Unpin for StatsWriter<W>
where W: Unpin,

§

impl<W> UnsafeUnpin for StatsWriter<W>
where W: UnsafeUnpin,

§

impl<W> UnwindSafe for StatsWriter<W>
where W: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSync for T
where T: Sync,