json.rs
This file
Path
src/export/json.rs
27 lines · 634 bytes · Rust
Last changed by
Move functionality to schedulerDavid Peterbefore adoptiondcfeede
History of this fileTake it
Flat directory/module structureDavid Peterbefore adoption30c381f
lines 1–2why, one step back1use serde::*;2use serde_json::to_vec_pretty;Re-order importsDavid Peterbefore adoption9df6174
lines 3–4why, one step back34use super::Exporter;Move functionality to schedulerDavid Peterbefore adoptiondcfeede
line 5why, one step back5use crate::benchmark::benchmark_result::BenchmarkResult;Move a few modules to utilDavid Peterbefore adoption5c634c9
line 6why, one step back6use crate::util::units::Unit;Flat directory/module structureDavid Peterbefore adoption30c381f
line 7why, one step back7Unified error handlingDavid Peterbefore adoption2040810
lines 8–9why, one step back8use anyhow::Result;9Flat directory/module structureDavid Peterbefore adoption30c381f
lines 10–24why, one step back10#[derive(Serialize, Debug)]11struct HyperfineSummary<'a> {12 results: &'a [BenchmarkResult],13}1415#[derive(Default)]16pub struct JsonExporter {}1718impl Exporter for JsonExporter {19 fn serialize(&self, results: &[BenchmarkResult], _unit: Option<Unit>) -> Result<Vec<u8>> {20 let mut output = to_vec_pretty(&HyperfineSummary { results });21 for content in output.iter_mut() {22 content.push(b'\n');23 }24Unified error handlingDavid Peterbefore adoption2040810
line 25why, one step back25 Ok(output?)Flat directory/module structureDavid Peterbefore adoption30c381f
lines 26–27why, one step back26 }27}