    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

    use serde::Deserialize;

    use crate::{AsResult, Parse};

    /// Marker of intended deployment environment.
    #[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize)]
    #[serde(rename_all = "lowercase")]
    pub enum Mode {
        /// Marks development environment.
        Development,

        /// Marks production environment.
        Production,
    }

    impl Parse for Mode {
        fn parse(string: &str) -> AsResult<Self> {
            match string {
                "development" => Ok(Self::Development),
                "production" => Ok(Self::Production),
                _ => Err(InvalidValue! {
                    expected: "\"development\" | \"production\".",
                    got: string,
                }),
            }
        }
    }