ed_journals/modules/civilization/models/
economy.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
90
91
92
93
94
95
96
97
98
use std::fmt::{Display, Formatter};

use serde::{Deserialize, Serialize};

/// A type of economy that can be related to a system or station.
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub enum Economy {
    #[serde(rename = "$economy_Agri;")]
    Agriculture,

    #[serde(rename = "$economy_Colony;")]
    Colony,

    #[serde(rename = "$economy_Service;")]
    Service,

    #[serde(rename = "$economy_Industrial;")]
    Industrial,

    #[serde(rename = "$economy_Refinery;")]
    Refinery,

    #[serde(rename = "$economy_Extraction;")]
    Extraction,

    #[serde(rename = "$economy_HighTech;")]
    HighTech,

    #[serde(rename = "$economy_Military;")]
    Military,

    #[serde(rename = "$economy_Carrier;")]
    PrivateEnterprise,

    #[serde(rename = "$economy_Tourism;")]
    Tourism,

    #[serde(rename = "$economy_Engineer;")]
    Engineer,

    #[serde(rename = "$economy_Terraforming;")]
    Terraforming,

    #[serde(rename = "$economy_Rescue;")]
    Rescue,

    #[serde(rename = "$economy_Damaged;")]
    Damaged,

    #[serde(rename = "$economy_Repair;")]
    Repair,

    #[serde(rename = "$economy_Prison;")]
    Prison,

    #[serde(rename = "$economy_Undefined;")]
    Undefined,

    #[serde(rename = "$economy_None;")]
    None,

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

impl Display for Economy {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        write!(
            f,
            "{}",
            match self {
                Economy::Agriculture => "Agriculture",
                Economy::Colony => "Colony",
                Economy::Service => "Service",
                Economy::Industrial => "Industrial",
                Economy::Refinery => "Refinery",
                Economy::Extraction => "Extraction",
                Economy::HighTech => "HighTech",
                Economy::Military => "Military",
                Economy::PrivateEnterprise => "Private Enterprise",
                Economy::Tourism => "Tourism",
                Economy::Engineer => "Engineer",
                Economy::Terraforming => "Terraforming",
                Economy::Rescue => "Rescue",
                Economy::Damaged => "Damaged",
                Economy::Repair => "Repair",
                Economy::Prison => "Prison",
                Economy::Undefined => "Undefined",
                Economy::None => "None",

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