use std::io;
use serde::Serialize;
use serde_json::{Map, Value};
use crate::error::CliError;
pub(crate) const AGGREGATE_VERSION: &str = "1";
#[derive(Debug, Serialize)]
pub(crate) struct AggregateV1<'a> {
pub(crate) aggregate_version: &'a str,
pub(crate) baseline: Option<&'a str>,
pub(crate) metrics: Vec<&'a str>,
pub(crate) rows: Vec<AggregateRow<'a>>,
}
#[derive(Debug, Serialize)]
pub(crate) struct AggregateRow<'a> {
pub(crate) axis: &'a str,
pub(crate) value: &'a str,
pub(crate) n_runs: u64,
pub(crate) metrics: Map<String, Value>,
}
pub(crate) fn render(doc: &AggregateV1<'_>, out: &mut dyn io::Write) -> Result<(), CliError> {
serde_json::to_writer(&mut *out, doc)?;
writeln!(out)?;
Ok(())
}