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
use crate::scenario_format::{
    interpret_trait::{InterpretableFrom, InterpreterContext, IntoRaw},
    serde_raw::CheckStorageRaw,
};

use super::CheckStorageDetails;

#[derive(Debug)]
pub enum CheckStorage {
    Star,
    Equal(CheckStorageDetails),
}

impl Default for CheckStorage {
    fn default() -> Self {
        CheckStorage::Star
    }
}

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

impl InterpretableFrom<CheckStorageRaw> for CheckStorage {
    fn interpret_from(from: CheckStorageRaw, context: &InterpreterContext) -> Self {
        match from {
            CheckStorageRaw::Star => CheckStorage::Star,
            CheckStorageRaw::Equal(m) => {
                CheckStorage::Equal(CheckStorageDetails::interpret_from(m, context))
            },
        }
    }
}

impl IntoRaw<CheckStorageRaw> for CheckStorage {
    fn into_raw(self) -> CheckStorageRaw {
        match self {
            CheckStorage::Star => CheckStorageRaw::Star,
            CheckStorage::Equal(details) => CheckStorageRaw::Equal(details.into_raw()),
        }
    }
}