1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use crate::scenario_format::{
    interpret_trait::{InterpretableFrom, InterpreterContext, IntoRaw},
    serde_raw::CheckDctMapRaw,
};

use super::CheckDctMapContents;

#[derive(Debug)]
pub enum CheckDctMap {
    Unspecified,
    Star,
    Equal(CheckDctMapContents),
}

impl Default for CheckDctMap {
    fn default() -> Self {
        CheckDctMap::Unspecified
    }
}

impl CheckDctMap {
    pub fn is_star(&self) -> bool {
        matches!(self, CheckDctMap::Star)
    }
}

impl InterpretableFrom<CheckDctMapRaw> for CheckDctMap {
    fn interpret_from(from: CheckDctMapRaw, context: &InterpreterContext) -> Self {
        match from {
            CheckDctMapRaw::Unspecified => CheckDctMap::Unspecified,
            CheckDctMapRaw::Star => CheckDctMap::Star,
            CheckDctMapRaw::Equal(m) => {
                CheckDctMap::Equal(CheckDctMapContents::interpret_from(m, context))
            },
        }
    }
}

impl IntoRaw<CheckDctMapRaw> for CheckDctMap {
    fn into_raw(self) -> CheckDctMapRaw {
        match self {
            CheckDctMap::Unspecified => CheckDctMapRaw::Unspecified,
            CheckDctMap::Star => CheckDctMapRaw::Star,
            CheckDctMap::Equal(value) => CheckDctMapRaw::Equal(value.into_raw()),
        }
    }
}