ed_journals/modules/civilization/models/
crime.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
use serde::{Deserialize, Serialize};

/// The kind of crime that can be committed.
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub enum Crime {
    Assault,
    Murder,
    Piracy,
    Interdiction,
    IllegalCargo,
    DisobeyPolice,
    FireInNoFireZone,
    FireInStation,
    DumpingDangerous,
    DumpingNearStation,
    RecklessWeaponsDischarge,
    PassengerWanted,
    ShuttleDestruction,

    #[serde(rename = "dockingMinorBlockingAirlock")]
    MinorBlockingAirlock,

    #[serde(rename = "dockingMajorBlockingAirlock")]
    MayorBlockingAirlock,

    #[serde(rename = "dockingMinorBlockingLandingPad")]
    MinorBlockingLandingPad,

    #[serde(rename = "dockingMajorBlockingLandingPad")]
    MajorBlockingLandingPad,

    #[serde(rename = "dockingMinorTresspass")]
    MinorTrespass,

    #[serde(rename = "dockingMajorTresspass")]
    MajorTrespass,
    CollidedAtSpeedInNoFireZone,

    #[serde(rename = "collidedAtSpeedInNoFireZone_hulldamage")]
    CollidedAtSpeedInNoFireZoneHullDamage,

    #[serde(rename = "onFoot_profileCloningIntent")]
    OnFootIdentityTheftCaught,

    #[serde(rename = "onFoot_murder")]
    OnFootMurder,

    #[serde(rename = "onFoot_identityTheft")]
    OnFootIdentityTheft,

    #[serde(rename = "onFoot_recklessEndangerment")]
    OnFootRecklessEndangerment,

    #[serde(rename = "onFoot_trespass")]
    OnFootTrespassing,

    #[serde(rename = "onFoot_detectionOfWeapon")]
    OnFootDetectionOfWeapon,

    #[serde(rename = "onFoot_failureToSubmitToPolice")]
    OnFootFailureToSubmitToPolice,

    #[serde(rename = "onFoot_carryingIllegalGoods")]
    OnFootCarryingIllegalGoods,

    #[serde(rename = "onFoot_arcCutterUse")]
    OnFootArcCutterUse,

    #[serde(rename = "onFoot_breakingAndEntering")]
    OnFootBreakingAndEntering,

    #[serde(rename = "onFoot_carryingIllegalData")]
    OnFootCarryingIllegalData,

    #[serde(rename = "onFoot_carryingStolenGoods")]
    OnFootCarryingStolenGoods,

    #[serde(rename = "onFoot_damagingDefences")]
    OnFootDamagingDefences,

    #[serde(rename = "onFoot_dataTransfer")]
    OnFootDataTransfer,

    #[serde(rename = "onFoot_eBreachUse")]
    OnFootEBreachUse,

    #[serde(rename = "onFoot_overchargeIntent")]
    OnFootOverchargeIntent,

    #[serde(rename = "onfoot_overchargedPort", alias = "onFoot_overchargedPort")]
    OnFootOverchargedPort,

    #[serde(rename = "onFoot_theft")]
    OnFootTheft,

    #[serde(rename = "onFoot_propertyTheft")]
    OnFootPropertyTheft,
}

#[cfg(test)]
mod tests {
    use crate::civilization::Crime;
    use serde_json::Value;

    #[test]
    fn all_crimes_are_parsed_correctly() {
        let content = include_str!("zz_crimes.txt");
        let lines = content.lines();

        for line in lines {
            if line.starts_with('#') {
                continue;
            }

            let result = serde_json::from_value::<Crime>(Value::String(line.to_string()));

            dbg!(&result);
            assert!(result.is_ok());
        }
    }
}