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
48
49
50
51
52
/*
    Appellation: apps <module>
    Contributors: FL03 <jo3mccain@icloud.com> (https://gitlab.com/FL03)
    Description:
        ... Summary ...
*/
#[doc(inline)]
pub use self::{configs::*, modes::ApplicationMode};

mod configs;

pub trait AppSpec {
    fn homepage(&self) -> String;
    fn name(&self) -> String;
    fn slug(&self) -> String {
        self.name().to_lowercase()
    }
}

pub(crate) mod modes {
    use serde::{Deserialize, Serialize};
    use strum::{EnumString, EnumVariantNames};

    #[derive(
        Clone, Debug, Deserialize, EnumString, EnumVariantNames, Eq, Hash, PartialEq, Serialize,
    )]
    #[strum(serialize_all = "snake_case")]
    pub enum ApplicationMode {
        Development,
        Staging,
        Production,
        Custom(String),
    }

    impl Default for ApplicationMode {
        fn default() -> Self {
            Self::try_from("development").expect("Failed")
        }
    }
}

#[cfg(test)]
mod tests {
    use super::ApplicationMode;

    #[test]
    fn test_default_application_mode() {
        let a = ApplicationMode::default();
        let b = ApplicationMode::Development;
        assert_eq!(a, b)
    }
}