ed_journals/modules/civilization/models/
system_security.rs

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
use std::fmt::{Display, Formatter};

use serde::{Deserialize, Serialize};

/// The level of security present in a system which controls how much security force is present in
/// the system.
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub enum SystemSecurity {
    #[serde(rename = "$SYSTEM_SECURITY_high;")]
    High,

    #[serde(rename = "$SYSTEM_SECURITY_medium;")]
    Medium,

    #[serde(rename = "$SYSTEM_SECURITY_low;")]
    Low,

    #[serde(rename = "$GAlAXY_MAP_INFO_state_anarchy;")]
    Anarchy,

    #[serde(rename = "$GALAXY_MAP_INFO_state_lawless;")]
    Lawless,

    #[cfg(feature = "allow-unknown")]
    #[cfg_attr(docsrs, doc(cfg(feature = "allow-unknown")))]
    #[serde(untagged)]
    Unknown(String),
}

impl Display for SystemSecurity {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        write!(
            f,
            "{}",
            match self {
                SystemSecurity::High => "High",
                SystemSecurity::Medium => "Medium",
                SystemSecurity::Low => "Low",
                SystemSecurity::Anarchy => "Anarchy",
                SystemSecurity::Lawless => "Lawless",

                #[cfg(feature = "allow-unknown")]
                SystemSecurity::Unknown(unknown) =>
                    return write!(f, "Unknown system security: {}", unknown),
            }
        )
    }
}