chord_core/
case.rs

1use std::fmt::Display;
2
3use chrono::{DateTime, Utc};
4
5use crate::collection::TailDropVec;
6use crate::step::StepAsset;
7use crate::task::TaskId;
8use crate::value::Value;
9
10pub type Error = Box<dyn std::error::Error + Sync + Send>;
11
12pub trait CaseId: Sync + Send + Display {
13    fn case(&self) -> &str;
14
15    fn exec_id(&self) -> &str;
16
17    fn stage_id(&self) -> &str;
18
19    fn task_id(&self) -> &dyn TaskId;
20}
21
22pub trait CaseAsset: Sync + Send {
23    fn id(&self) -> &dyn CaseId;
24
25    fn start(&self) -> DateTime<Utc>;
26
27    fn end(&self) -> DateTime<Utc>;
28
29    fn data(&self) -> &Value;
30
31    fn state(&self) -> &CaseState;
32}
33
34pub enum CaseState {
35    Ok(TailDropVec<Box<dyn StepAsset>>),
36    Err(Box<Error>),
37    Fail(TailDropVec<Box<dyn StepAsset>>),
38}
39
40impl CaseState {
41    pub fn is_ok(&self) -> bool {
42        match self {
43            CaseState::Ok(_) => true,
44            _ => false,
45        }
46    }
47}