1use std::{str::FromStr, time::Duration};
2
3use serde::{Deserialize, Serialize};
4
5#[derive(Serialize, Deserialize, Debug)]
6pub struct Report {
7 pub status: ReportStatus,
8}
9
10impl Report {
11 pub fn pending() -> Self {
12 Self {
13 status: ReportStatus::Pending,
14 }
15 }
16
17 pub fn ready(info: ReportInfo) -> Self {
18 Self {
19 status: ReportStatus::Ready(info),
20 }
21 }
22}
23
24#[derive(Serialize, Deserialize, Debug)]
25pub enum ReportStatus {
26 Pending,
27 Ready(ReportInfo),
28}
29
30#[derive(Serialize, Deserialize, Debug)]
31pub struct ReportInfo {
32 pub time: Duration,
33 pub tests: Vec<TestResult>,
34}
35
36#[derive(Serialize, Deserialize, Debug)]
37pub struct TestResult {
38 pub name: String,
39 pub passed: bool,
40}
41
42impl FromStr for Report {
43 type Err = serde_json::Error;
44
45 fn from_str(s: &str) -> Result<Self, Self::Err> {
46 serde_json::from_str(s)
47 }
48}