ed_journals/modules/civilization/models/
government.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
use std::fmt::{Display, Formatter};

use serde::{Deserialize, Serialize};

/// The type of government.
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub enum Government {
    #[serde(alias = "$government_Anarchy;")]
    Anarchy,

    #[serde(alias = "$government_Communism;")]
    Communism,

    #[serde(alias = "$government_Confederacy;")]
    Confederacy,

    #[serde(alias = "$government_Cooperative;")]
    Cooperative,

    #[serde(alias = "$government_Corporate;")]
    Corporate,

    #[serde(alias = "$government_Democracy;")]
    Democracy,

    #[serde(alias = "$government_Dictatorship;")]
    Dictatorship,

    #[serde(alias = "$government_Feudal;")]
    Feudal,

    #[serde(alias = "$government_Patronage;")]
    Patronage,

    #[serde(alias = "$government_PrisonColony;")]
    PrisonColony,

    #[serde(alias = "$government_Theocracy;")]
    Theocracy,

    #[serde(alias = "$government_Engineer;")]
    Engineer,

    #[serde(alias = "$government_None;")]
    None,

    #[serde(alias = "$government_Prison;")]
    Prison,

    /// Private ownership indicates a fleet carrier that is owned by a player.
    #[serde(alias = "$government_Carrier;")]
    PrivateOwnership,

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

impl Display for Government {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        write!(
            f,
            "{}",
            match self {
                Government::Anarchy => "Anarchy",
                Government::Communism => "Communism",
                Government::Confederacy => "Confederacy",
                Government::Cooperative => "Cooperative",
                Government::Corporate => "Corporate",
                Government::Democracy => "Democracy",
                Government::Dictatorship => "Dictatorship",
                Government::Engineer => "Engineer",
                Government::Feudal => "Feudal",
                Government::Patronage => "Patronage",
                Government::Prison => "Prison",
                Government::PrisonColony => "Prison Colony",
                Government::PrivateOwnership => "Private Ownership",
                Government::Theocracy => "Theocracy",

                Government::None => "None",

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