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: u32Schema version. Tracks the same number as Report::schema_version.
subject: StringCrate or project being reported on.
subject_version: StringVersion 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
impl MultiReport
Sourcepub fn new(
subject: impl Into<String>,
subject_version: impl Into<String>,
) -> Self
pub fn new( subject: impl Into<String>, subject_version: impl Into<String>, ) -> Self
Begin a new aggregate for the given subject and version.
Sourcepub fn overall_verdict(&self) -> Verdict
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.
Sourcepub fn total_check_count(&self) -> usize
pub fn total_check_count(&self) -> usize
Total number of checks across all constituent reports.
Sourcepub fn iter_checks(&self) -> impl Iterator<Item = (Option<&str>, &CheckResult)>
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.
Sourcepub fn checks_with_tag<'a>(
&'a self,
tag: &'a str,
) -> impl Iterator<Item = (Option<&'a str>, &'a CheckResult)>
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"));Trait Implementations§
Source§impl Clone for MultiReport
impl Clone for MultiReport
Source§fn clone(&self) -> MultiReport
fn clone(&self) -> MultiReport
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more