1#[derive(idris_derive::Idris)]
2#[idris(repr = usize)]
3#[derive(serde::Serialize, serde::Deserialize)]
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
5#[cfg_attr(feature = "ts_export", derive(ts_rs::TS))]
6pub enum ArtifactType {
7 Attraction,
8 Blood,
9 Bobblehead,
10 Clue,
11 Contraption,
12 Equipment,
13 Food,
14 Fortification,
15 Gold,
16 Incubator,
17 Infinity,
18 Junk,
19 Map,
20 Powerstone,
21 Spacecraft,
22 Stone,
23 Terminus,
24 Treasure,
25 Vehicle,
26}
27
28impl std::str::FromStr for ArtifactType {
29 type Err = crate::ParsingError;
30 fn from_str(s: &str) -> Result<Self, Self::Err> {
31 match s {
32 "attraction" => Ok(Self::Attraction),
33 "blood" => Ok(Self::Blood),
34 "bobblehead" => Ok(Self::Bobblehead),
35 "clue" => Ok(Self::Clue),
36 "contraption" => Ok(Self::Contraption),
37 "equipment" => Ok(Self::Equipment),
38 "food" => Ok(Self::Food),
39 "fortification" => Ok(Self::Fortification),
40 "gold" => Ok(Self::Gold),
41 "incubator" => Ok(Self::Incubator),
42 "infinity" => Ok(Self::Infinity),
43 "junk" => Ok(Self::Junk),
44 "map" => Ok(Self::Map),
45 "powerstone" => Ok(Self::Powerstone),
46 "spacecraft" => Ok(Self::Spacecraft),
47 "stone" => Ok(Self::Stone),
48 "terminus" => Ok(Self::Terminus),
49 "treasure" => Ok(Self::Treasure),
50 "vehicle" => Ok(Self::Vehicle),
51 _ => Err(crate::ParsingError {
52 item: "ArtifactType",
53 message: "provided source does not match",
54 }),
55 }
56 }
57}
58
59impl ArtifactType {
60 pub fn as_str(&self) -> &'static str {
61 match self {
62 Self::Attraction => "attraction",
63 Self::Blood => "blood",
64 Self::Bobblehead => "bobblehead",
65 Self::Clue => "clue",
66 Self::Contraption => "contraption",
67 Self::Equipment => "equipment",
68 Self::Food => "food",
69 Self::Fortification => "fortification",
70 Self::Gold => "gold",
71 Self::Incubator => "incubator",
72 Self::Infinity => "infinity",
73 Self::Junk => "junk",
74 Self::Map => "map",
75 Self::Powerstone => "powerstone",
76 Self::Spacecraft => "spacecraft",
77 Self::Stone => "stone",
78 Self::Terminus => "terminus",
79 Self::Treasure => "treasure",
80 Self::Vehicle => "vehicle",
81 }
82 }
83}
84
85impl std::fmt::Display for ArtifactType {
86 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
87 write!(f, "{}", self.as_str())
88 }
89}
90
91impl ArtifactType {
92 pub fn all() -> impl Iterator<Item = Self> {
93 [
94 Self::Attraction,
95 Self::Blood,
96 Self::Bobblehead,
97 Self::Clue,
98 Self::Contraption,
99 Self::Equipment,
100 Self::Food,
101 Self::Fortification,
102 Self::Gold,
103 Self::Incubator,
104 Self::Infinity,
105 Self::Junk,
106 Self::Map,
107 Self::Powerstone,
108 Self::Spacecraft,
109 Self::Stone,
110 Self::Terminus,
111 Self::Treasure,
112 Self::Vehicle,
113 ].into_iter()
114 }
115}