coc_rs/models/
location.rs

1use serde::{Deserialize, Serialize};
2use serde_repr::{Deserialize_repr, Serialize_repr};
3
4#[derive(Debug, Serialize, Deserialize, Clone)]
5pub struct Location {
6    #[serde(rename = "id")]
7    pub id: Local,
8
9    #[serde(rename = "name")]
10    pub name: String,
11
12    #[serde(rename = "isCountry")]
13    pub is_country: bool,
14}
15
16#[derive(
17    Debug,
18    Clone,
19    Copy,
20    Serialize_repr,
21    Deserialize_repr,
22    PartialEq,
23    Eq,
24    PartialOrd,
25    Ord,
26    ToPrimitive,
27    FromPrimitive,
28)]
29#[repr(i32)]
30pub enum Local {
31    None = 0,
32    Europe = 32_000_000,
33    NorthAmerica = 32_000_001,
34    SouthAmerica = 32_000_002,
35    Asia = 32_000_003,
36    AustraliaContinent = 32_000_004,
37    Africa = 32_000_005,
38    International = 32_000_006,
39    Afghanistan = 32_000_007,
40    ÅlandIslands = 32_000_008,
41    Albania = 32_000_009,
42    Algeria = 32_000_010,
43    AmericanSamoa = 32_000_011,
44    Andorra = 32_000_012,
45    Angola = 32_000_013,
46    Anguilla = 32_000_014,
47    Antarctica = 32_000_015,
48    AntiguaAndBarbuda = 32_000_016,
49    Argentina = 32_000_017,
50    Armenia = 32_000_018,
51    Aruba = 32_000_019,
52    AscensionIsland = 32_000_020,
53    Australia = 32_000_021,
54    Austria = 32_000_022,
55    Azerbaijan = 32_000_023,
56    Bahamas = 32_000_024,
57    Bahrain = 32_000_025,
58    Bangladesh = 32_000_026,
59    Barbados = 32_000_027,
60    Belarus = 32_000_028,
61    Belgium = 32_000_029,
62    Belize = 32_000_030,
63    Benin = 32_000_031,
64    Bermuda = 32_000_032,
65    Bhutan = 32_000_033,
66    Bolivia = 32_000_034,
67    BosniaAndHerzegovina = 32_000_035,
68    Botswana = 32_000_036,
69    BouvetIsland = 32_000_037,
70    Brazil = 32_000_038,
71    BritishIndianOceanTerritory = 32_000_039,
72    BritishVirginIslands = 32_000_040,
73    Brunei = 32_000_041,
74    Bulgaria = 32_000_042,
75    BurkinaFaso = 32_000_043,
76    Burundi = 32_000_044,
77    Cambodia = 32_000_045,
78    Cameroon = 32_000_046,
79    Canada = 32_000_047,
80    CanaryIslands = 32_000_048,
81    CapeVerde = 32_000_049,
82    CaribbeanNetherlands = 32_000_050,
83    CaymanIslands = 32_000_051,
84    CentralAfricanRepublic = 32_000_052,
85    CeutaAndMelilla = 32_000_053,
86    Chad = 32_000_054,
87    Chile = 32_000_055,
88    China = 32_000_056,
89    ChristmasIsland = 32_000_057,
90    CocosIslands = 32_000_058,
91    Colombia = 32_000_059,
92    Comoros = 32_000_060,
93    CongoDRC = 32_000_061,
94    CongoRepublic = 32_000_062,
95    CookIslands = 32_000_063,
96    CostaRica = 32_000_064,
97    CôtedIvoire = 32_000_065,
98    Croatia = 32_000_066,
99    Cuba = 32_000_067,
100    Curaçao = 32_000_068,
101    Cyprus = 32_000_069,
102    CzechRepublic = 32_000_070,
103    Denmark = 32_000_071,
104    DiegoGarcia = 32_000_072,
105    Djibouti = 32_000_073,
106    Dominica = 32_000_074,
107    DominicanRepublic = 32_000_075,
108    Ecuador = 32_000_076,
109    Egypt = 32_000_077,
110    ElSalvador = 32_000_078,
111    EquatorialGuinea = 32_000_079,
112    Eritrea = 32_000_080,
113    Estonia = 32_000_081,
114    Ethiopia = 32_000_082,
115    FalklandIslands = 32_000_083,
116    FaroeIslands = 32_000_084,
117    Fiji = 32_000_085,
118    Finland = 32_000_086,
119    France = 32_000_087,
120    FrenchGuiana = 32_000_088,
121    FrenchPolynesia = 32_000_089,
122    FrenchSouthernTerritories = 32_000_090,
123    Gabon = 32_000_091,
124    Gambia = 32_000_092,
125    Georgia = 32_000_093,
126    Germany = 32_000_094,
127    Ghana = 32_000_095,
128    Gibraltar = 32_000_096,
129    Greece = 32_000_097,
130    Greenland = 32_000_098,
131    Grenada = 32_000_099,
132    Guadeloupe = 32_000_100,
133    Guam = 32_000_101,
134    Guatemala = 32_000_102,
135    Guernsey = 32_000_103,
136    Guinea = 32_000_104,
137    GuineaBissau = 32_000_105,
138    Guyana = 32_000_106,
139    Haiti = 32_000_107,
140    HeardAndMcDonaldIslands = 32_000_108,
141    Honduras = 32_000_109,
142    HongKong = 32_000_110,
143    Hungary = 32_000_111,
144    Iceland = 32_000_112,
145    India = 32_000_113,
146    Indonesia = 32_000_114,
147    Iran = 32_000_115,
148    Iraq = 32_000_116,
149    Ireland = 32_000_117,
150    IsleOfMan = 32_000_118,
151    Israel = 32_000_119,
152    Italy = 32_000_120,
153    Jamaica = 32_000_121,
154    Japan = 32_000_122,
155    Jersey = 32_000_123,
156    Jordan = 32_000_124,
157    Kazakhstan = 32_000_125,
158    Kenya = 32_000_126,
159    Kiribati = 32_000_127,
160    Kosovo = 32_000_128,
161    Kuwait = 32_000_129,
162    Kyrgyzstan = 32_000_130,
163    Laos = 32_000_131,
164    Latvia = 32_000_132,
165    Lebanon = 32_000_133,
166    Lesotho = 32_000_134,
167    Liberia = 32_000_135,
168    Libya = 32_000_136,
169    Liechtenstein = 32_000_137,
170    Lithuania = 32_000_138,
171    Luxembourg = 32_000_139,
172    Macau = 32_000_140,
173    NorthMacedonia = 32_000_141,
174    Madagascar = 32_000_142,
175    Malawi = 32_000_143,
176    Malaysia = 32_000_144,
177    Maldives = 32_000_145,
178    Mali = 32_000_146,
179    Malta = 32_000_147,
180    MarshallIslands = 32_000_148,
181    Martinique = 32_000_149,
182    Mauritania = 32_000_150,
183    Mauritius = 32_000_151,
184    Mayotte = 32_000_152,
185    Mexico = 32_000_153,
186    Micronesia = 32_000_154,
187    Moldova = 32_000_155,
188    Monaco = 32_000_156,
189    Mongolia = 32_000_157,
190    Montenegro = 32_000_158,
191    Montserrat = 32_000_159,
192    Morocco = 32_000_160,
193    Mozambique = 32_000_161,
194    Myanmar = 32_000_162,
195    Namibia = 32_000_163,
196    Nauru = 32_000_164,
197    Nepal = 32_000_165,
198    Netherlands = 32_000_166,
199    NewCaledonia = 32_000_167,
200    NewZealand = 32_000_168,
201    Nicaragua = 32_000_169,
202    Niger = 32_000_170,
203    Nigeria = 32_000_171,
204    Niue = 32_000_172,
205    NorfolkIsland = 32_000_173,
206    NorthKorea = 32_000_174,
207    NorthernMarianaIslands = 32_000_175,
208    Norway = 32_000_176,
209    Oman = 32_000_177,
210    Pakistan = 32_000_178,
211    Palau = 32_000_179,
212    Palestine = 32_000_180,
213    Panama = 32_000_181,
214    PapuaNewGuinea = 32_000_182,
215    Paraguay = 32_000_183,
216    Peru = 32_000_184,
217    Philippines = 32_000_185,
218    PitcairnIslands = 32_000_186,
219    Poland = 32_000_187,
220    Portugal = 32_000_188,
221    PuertoRico = 32_000_189,
222    Qatar = 32_000_190,
223    Réunion = 32_000_191,
224    Romania = 32_000_192,
225    Russia = 32_000_193,
226    Rwanda = 32_000_194,
227    SaintBarthélemy = 32_000_195,
228    SaintHelena = 32_000_196,
229    SaintKittsAndNevis = 32_000_197,
230    SaintLucia = 32_000_198,
231    SaintMartin = 32_000_199,
232    SaintPierreAndMiquelon = 32_000_200,
233    Samoa = 32_000_201,
234    SanMarino = 32_000_202,
235    SãoToméAndPríncipe = 32_000_203,
236    SaudiArabia = 32_000_204,
237    Senegal = 32_000_205,
238    Serbia = 32_000_206,
239    Seychelles = 32_000_207,
240    SierraLeone = 32_000_208,
241    Singapore = 32_000_209,
242    SintMaarten = 32_000_210,
243    Slovakia = 32_000_211,
244    Slovenia = 32_000_212,
245    SolomonIslands = 32_000_213,
246    Somalia = 32_000_214,
247    SouthAfrica = 32_000_215,
248    SouthKorea = 32_000_216,
249    SouthSudan = 32_000_217,
250    Spain = 32_000_218,
251    SriLanka = 32_000_219,
252    StVincentAndGrenadines = 32_000_220,
253    Sudan = 32_000_221,
254    Suriname = 32_000_222,
255    SvalbardAndJanMayen = 32_000_223,
256    Swaziland = 32_000_224,
257    Sweden = 32_000_225,
258    Switzerland = 32_000_226,
259    Syria = 32_000_227,
260    Taiwan = 32_000_228,
261    Tajikistan = 32_000_229,
262    Tanzania = 32_000_230,
263    Thailand = 32_000_231,
264    TimorLeste = 32_000_232,
265    Togo = 32_000_233,
266    Tokelau = 32_000_234,
267    Tonga = 32_000_235,
268    TrinidadAndTobago = 32_000_236,
269    TristanDaCunha = 32_000_237,
270    Tunisia = 32_000_238,
271    Turkey = 32_000_239,
272    Turkmenistan = 32_000_240,
273    TurksAndCaicosIslands = 32_000_241,
274    Tuvalu = 32_000_242,
275    USOutlyingIslands = 32_000_243,
276    USVirginIslands = 32_000_244,
277    Uganda = 32_000_245,
278    Ukraine = 32_000_246,
279    UnitedArabEmirates = 32_000_247,
280    UnitedKingdom = 32_000_248,
281    UnitedStates = 32_000_249,
282    Uruguay = 32_000_250,
283    Uzbekistan = 32_000_251,
284    Vanuatu = 32_000_252,
285    VaticanCity = 32_000_253,
286    Venezuela = 32_000_254,
287    Vietnam = 32_000_255,
288    WallisAndFutuna = 32_000_256,
289    WesternSahara = 32_000_257,
290    Yemen = 32_000_258,
291    Zambia = 32_000_259,
292    Zimbabwe = 32_000_260,
293    DoNotUse1 = 32_000_261,
294    DoNotUse2 = 32_000_262,
295    DoNotUse3 = 32_000_263,
296    DoNotUse4 = 32_000_264,
297    DoNotUse5 = 32_000_265,
298}
299
300impl std::fmt::Display for Local {
301    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
302        std::fmt::Debug::fmt(self, f)
303    }
304}
305
306impl Default for Local {
307    fn default() -> Self {
308        Self::None
309    }
310}
311
312impl Local {
313    #[must_use]
314    pub fn from_i32(num: i32) -> Option<Self> {
315        num_traits::FromPrimitive::from_i32(num)
316    }
317
318    #[must_use]
319    pub fn from_u32(num: u32) -> Option<Self> {
320        num_traits::FromPrimitive::from_u32(num)
321    }
322
323    #[must_use]
324    pub fn from_usize(num: usize) -> Option<Self> {
325        num_traits::FromPrimitive::from_usize(num)
326    }
327
328    #[must_use]
329    pub fn to_i32(&self) -> i32 {
330        num_traits::ToPrimitive::to_i32(self).unwrap_or_default()
331    }
332
333    #[must_use]
334    pub fn to_u32(&self) -> u32 {
335        num_traits::ToPrimitive::to_u32(self).unwrap_or_default()
336    }
337
338    #[must_use]
339    pub fn to_usize(&self) -> usize {
340        num_traits::ToPrimitive::to_usize(self).unwrap_or_default()
341    }
342}