Skip to main content

MultiReport

Struct MultiReport 

Source
pub struct MultiReport {
    pub schema_version: u32,
    pub subject: String,
    pub subject_version: String,
    pub started_at: DateTime<Utc>,
    pub finished_at: Option<DateTime<Utc>>,
    pub reports: Vec<Report>,
}
Expand description

Aggregate of multiple Reports emitted in a single run.

Identity of a check is (producer, name). Two checks with the same name from different producers are kept separate.

§Example

use dev_report::{CheckResult, MultiReport, Report, Severity, Verdict};

let mut bench = Report::new("crate", "0.1.0").with_producer("dev-bench");
bench.push(CheckResult::pass("hot_path"));

let mut chaos = Report::new("crate", "0.1.0").with_producer("dev-chaos");
chaos.push(CheckResult::fail("recover", Severity::Error));

let mut multi = MultiReport::new("crate", "0.1.0");
multi.push(bench);
multi.push(chaos);
multi.finish();

assert_eq!(multi.overall_verdict(), Verdict::Fail);
assert_eq!(multi.total_check_count(), 2);

Fields§

§schema_version: u32

Schema version. Tracks the same number as Report::schema_version.

§subject: String

Crate or project being reported on.

§subject_version: String

Version of the subject.

§started_at: DateTime<Utc>

When aggregation started.

§finished_at: Option<DateTime<Utc>>

When aggregation finished, if known.

§reports: Vec<Report>

Constituent reports.

Implementations§

Source§

impl MultiReport

Source

pub fn new( subject: impl Into<String>, subject_version: impl Into<String>, ) -> Self

Begin a new aggregate for the given subject and version.

Examples found in repository?
examples/schema_sample.rs (line 106)
101fn build_multi() -> MultiReport {
102    let frozen_start = chrono::Utc.with_ymd_and_hms(2026, 5, 11, 12, 0, 0).unwrap();
103    let frozen_end = chrono::Utc
104        .with_ymd_and_hms(2026, 5, 11, 12, 0, 10)
105        .unwrap();
106    let mut m = MultiReport::new("sample-subject", "0.9.3");
107    m.started_at = frozen_start;
108    m.push(build_report("dev-bench"));
109    m.push(build_report("dev-chaos"));
110    m.finished_at = Some(frozen_end);
111    m
112}
Source

pub fn push(&mut self, r: Report)

Append a constituent report.

Examples found in repository?
examples/schema_sample.rs (line 108)
101fn build_multi() -> MultiReport {
102    let frozen_start = chrono::Utc.with_ymd_and_hms(2026, 5, 11, 12, 0, 0).unwrap();
103    let frozen_end = chrono::Utc
104        .with_ymd_and_hms(2026, 5, 11, 12, 0, 10)
105        .unwrap();
106    let mut m = MultiReport::new("sample-subject", "0.9.3");
107    m.started_at = frozen_start;
108    m.push(build_report("dev-bench"));
109    m.push(build_report("dev-chaos"));
110    m.finished_at = Some(frozen_end);
111    m
112}
Source

pub fn finish(&mut self)

Mark aggregation finished, stamping the finish time.

Source

pub fn overall_verdict(&self) -> Verdict

Compute the overall verdict across every check in every report.

Follows the same precedence as Report::overall_verdict: Fail > Warn > Pass > Skip.

Source

pub fn total_check_count(&self) -> usize

Total number of checks across all constituent reports.

Source

pub fn iter_reports(&self) -> impl Iterator<Item = &Report>

Iterate over the constituent reports.

Equivalent to self.reports.iter() but reads cleaner at the call site and makes the public iteration API explicit.

§Example
use dev_report::{CheckResult, MultiReport, Report};

let mut bench = Report::new("c", "0.1.0").with_producer("dev-bench");
bench.push(CheckResult::pass("hot"));
let mut multi = MultiReport::new("c", "0.1.0");
multi.push(bench);

for r in multi.iter_reports() {
    assert_eq!(r.subject, "c");
}
Source

pub fn report_from(&self, producer: &str) -> Option<&Report>

Find the constituent report from a specific producer, if any.

Returns the first match (MultiReport doesn’t enforce uniqueness; producers can appear multiple times).

§Example
use dev_report::{CheckResult, MultiReport, Report};

let mut bench = Report::new("c", "0.1.0").with_producer("dev-bench");
bench.push(CheckResult::pass("hot"));
let mut multi = MultiReport::new("c", "0.1.0");
multi.push(bench);

let found = multi.report_from("dev-bench").unwrap();
assert_eq!(found.checks.len(), 1);
Source

pub fn verdict_counts(&self) -> (usize, usize, usize, usize)

Aggregate verdict counts across all constituent reports as (pass, fail, warn, skip).

§Example
use dev_report::{CheckResult, MultiReport, Report, Severity};

let mut a = Report::new("c", "0.1.0").with_producer("a");
a.push(CheckResult::pass("x"));
a.push(CheckResult::fail("y", Severity::Error));
let mut b = Report::new("c", "0.1.0").with_producer("b");
b.push(CheckResult::pass("z"));
let mut multi = MultiReport::new("c", "0.1.0");
multi.push(a);
multi.push(b);
assert_eq!(multi.verdict_counts(), (2, 1, 0, 0));
Source

pub fn iter_checks(&self) -> impl Iterator<Item = (Option<&str>, &CheckResult)>

Iterate over every check across every constituent report, paired with the producer that emitted it.

Producers without a producer field are emitted as None.

Source

pub fn checks_with_tag<'a>( &'a self, tag: &'a str, ) -> impl Iterator<Item = (Option<&'a str>, &'a CheckResult)>

Iterate over checks carrying the given tag, paired with their producer.

§Example
use dev_report::{CheckResult, MultiReport, Report};

let mut bench = Report::new("c", "0.1.0").with_producer("dev-bench");
bench.push(CheckResult::pass("hot").with_tag("slow"));
bench.push(CheckResult::pass("cold"));

let mut multi = MultiReport::new("c", "0.1.0");
multi.push(bench);

let slow: Vec<_> = multi.checks_with_tag("slow").collect();
assert_eq!(slow.len(), 1);
assert_eq!(slow[0].0, Some("dev-bench"));
Source

pub fn to_json(&self) -> Result<String>

Serialize this multi-report to JSON.

Examples found in repository?
examples/schema_sample.rs (line 119)
114fn main() {
115    let arg = std::env::args()
116        .nth(1)
117        .unwrap_or_else(|| "report".to_string());
118    let json = match arg.as_str() {
119        "multi" => build_multi().to_json().expect("serialize MultiReport"),
120        _ => build_report("dev-bench")
121            .to_json()
122            .expect("serialize Report"),
123    };
124    println!("{}", json);
125}
Source

pub fn from_json(s: &str) -> Result<Self>

Deserialize a multi-report from JSON.

Source

pub fn passed(&self) -> bool

true when overall_verdict is Pass.

Source

pub fn failed(&self) -> bool

true when overall_verdict is Fail.

Source

pub fn warned(&self) -> bool

true when overall_verdict is Warn.

Source

pub fn skipped(&self) -> bool

true when overall_verdict is Skip.

Source

pub fn checks_with_severity( &self, severity: Severity, ) -> impl Iterator<Item = (Option<&str>, &CheckResult)>

Iterate over checks with the given severity, paired with their producer.

§Example
use dev_report::{CheckResult, MultiReport, Report, Severity};

let mut bench = Report::new("c", "0.1.0").with_producer("dev-bench");
bench.push(CheckResult::fail("a", Severity::Error));

let mut multi = MultiReport::new("c", "0.1.0");
multi.push(bench);

let errors: Vec<_> = multi.checks_with_severity(Severity::Error).collect();
assert_eq!(errors.len(), 1);
Source

pub fn to_terminal(&self) -> String

Available on crate feature terminal only.

Render this multi-report to a TTY-friendly string. Monochrome.

Available with the terminal feature.

Source

pub fn to_terminal_color(&self) -> String

Available on crate feature terminal only.

Render this multi-report with ANSI color codes.

Available with the terminal feature.

Source

pub fn to_markdown(&self) -> String

Available on crate feature markdown only.

Render this multi-report to a Markdown string.

Available with the markdown feature.

Source

pub fn to_sarif(&self) -> String

Available on crate feature sarif only.

Render this multi-report as a SARIF 2.1.0 document.

Each constituent Report becomes its own SARIF run, so consumers can tell which producer emitted which finding. Only Fail and Warn checks are emitted.

Available with the sarif feature.

Source

pub fn to_junit_xml(&self) -> String

Available on crate feature junit only.

Render this multi-report as a JUnit XML document with one <testsuite> per constituent Report.

Available with the junit feature.

Trait Implementations§

Source§

impl Clone for MultiReport

Source§

fn clone(&self) -> MultiReport

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MultiReport

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for MultiReport

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for MultiReport

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,