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.

Source

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

Append a constituent report.

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_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.

Source

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

Deserialize a multi-report from JSON.

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