coc-rs 0.8.4

A Rust crate wrapper around the Clash of Clans public API
Documentation
use serde::{Deserialize, Serialize};
use serde_repr::{Deserialize_repr, Serialize_repr};

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Location {
    #[serde(rename = "id")]
    pub id: Local,

    #[serde(rename = "name")]
    pub name: String,

    #[serde(rename = "isCountry")]
    pub is_country: bool,
}

#[derive(
    Debug,
    Clone,
    Copy,
    Serialize_repr,
    Deserialize_repr,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    ToPrimitive,
    FromPrimitive,
)]
#[repr(i32)]
pub enum Local {
    None = 0,
    Europe = 32_000_000,
    NorthAmerica = 32_000_001,
    SouthAmerica = 32_000_002,
    Asia = 32_000_003,
    AustraliaContinent = 32_000_004,
    Africa = 32_000_005,
    International = 32_000_006,
    Afghanistan = 32_000_007,
    ÅlandIslands = 32_000_008,
    Albania = 32_000_009,
    Algeria = 32_000_010,
    AmericanSamoa = 32_000_011,
    Andorra = 32_000_012,
    Angola = 32_000_013,
    Anguilla = 32_000_014,
    Antarctica = 32_000_015,
    AntiguaAndBarbuda = 32_000_016,
    Argentina = 32_000_017,
    Armenia = 32_000_018,
    Aruba = 32_000_019,
    AscensionIsland = 32_000_020,
    Australia = 32_000_021,
    Austria = 32_000_022,
    Azerbaijan = 32_000_023,
    Bahamas = 32_000_024,
    Bahrain = 32_000_025,
    Bangladesh = 32_000_026,
    Barbados = 32_000_027,
    Belarus = 32_000_028,
    Belgium = 32_000_029,
    Belize = 32_000_030,
    Benin = 32_000_031,
    Bermuda = 32_000_032,
    Bhutan = 32_000_033,
    Bolivia = 32_000_034,
    BosniaAndHerzegovina = 32_000_035,
    Botswana = 32_000_036,
    BouvetIsland = 32_000_037,
    Brazil = 32_000_038,
    BritishIndianOceanTerritory = 32_000_039,
    BritishVirginIslands = 32_000_040,
    Brunei = 32_000_041,
    Bulgaria = 32_000_042,
    BurkinaFaso = 32_000_043,
    Burundi = 32_000_044,
    Cambodia = 32_000_045,
    Cameroon = 32_000_046,
    Canada = 32_000_047,
    CanaryIslands = 32_000_048,
    CapeVerde = 32_000_049,
    CaribbeanNetherlands = 32_000_050,
    CaymanIslands = 32_000_051,
    CentralAfricanRepublic = 32_000_052,
    CeutaAndMelilla = 32_000_053,
    Chad = 32_000_054,
    Chile = 32_000_055,
    China = 32_000_056,
    ChristmasIsland = 32_000_057,
    CocosIslands = 32_000_058,
    Colombia = 32_000_059,
    Comoros = 32_000_060,
    CongoDRC = 32_000_061,
    CongoRepublic = 32_000_062,
    CookIslands = 32_000_063,
    CostaRica = 32_000_064,
    CôtedIvoire = 32_000_065,
    Croatia = 32_000_066,
    Cuba = 32_000_067,
    Curaçao = 32_000_068,
    Cyprus = 32_000_069,
    CzechRepublic = 32_000_070,
    Denmark = 32_000_071,
    DiegoGarcia = 32_000_072,
    Djibouti = 32_000_073,
    Dominica = 32_000_074,
    DominicanRepublic = 32_000_075,
    Ecuador = 32_000_076,
    Egypt = 32_000_077,
    ElSalvador = 32_000_078,
    EquatorialGuinea = 32_000_079,
    Eritrea = 32_000_080,
    Estonia = 32_000_081,
    Ethiopia = 32_000_082,
    FalklandIslands = 32_000_083,
    FaroeIslands = 32_000_084,
    Fiji = 32_000_085,
    Finland = 32_000_086,
    France = 32_000_087,
    FrenchGuiana = 32_000_088,
    FrenchPolynesia = 32_000_089,
    FrenchSouthernTerritories = 32_000_090,
    Gabon = 32_000_091,
    Gambia = 32_000_092,
    Georgia = 32_000_093,
    Germany = 32_000_094,
    Ghana = 32_000_095,
    Gibraltar = 32_000_096,
    Greece = 32_000_097,
    Greenland = 32_000_098,
    Grenada = 32_000_099,
    Guadeloupe = 32_000_100,
    Guam = 32_000_101,
    Guatemala = 32_000_102,
    Guernsey = 32_000_103,
    Guinea = 32_000_104,
    GuineaBissau = 32_000_105,
    Guyana = 32_000_106,
    Haiti = 32_000_107,
    HeardAndMcDonaldIslands = 32_000_108,
    Honduras = 32_000_109,
    HongKong = 32_000_110,
    Hungary = 32_000_111,
    Iceland = 32_000_112,
    India = 32_000_113,
    Indonesia = 32_000_114,
    Iran = 32_000_115,
    Iraq = 32_000_116,
    Ireland = 32_000_117,
    IsleOfMan = 32_000_118,
    Israel = 32_000_119,
    Italy = 32_000_120,
    Jamaica = 32_000_121,
    Japan = 32_000_122,
    Jersey = 32_000_123,
    Jordan = 32_000_124,
    Kazakhstan = 32_000_125,
    Kenya = 32_000_126,
    Kiribati = 32_000_127,
    Kosovo = 32_000_128,
    Kuwait = 32_000_129,
    Kyrgyzstan = 32_000_130,
    Laos = 32_000_131,
    Latvia = 32_000_132,
    Lebanon = 32_000_133,
    Lesotho = 32_000_134,
    Liberia = 32_000_135,
    Libya = 32_000_136,
    Liechtenstein = 32_000_137,
    Lithuania = 32_000_138,
    Luxembourg = 32_000_139,
    Macau = 32_000_140,
    NorthMacedonia = 32_000_141,
    Madagascar = 32_000_142,
    Malawi = 32_000_143,
    Malaysia = 32_000_144,
    Maldives = 32_000_145,
    Mali = 32_000_146,
    Malta = 32_000_147,
    MarshallIslands = 32_000_148,
    Martinique = 32_000_149,
    Mauritania = 32_000_150,
    Mauritius = 32_000_151,
    Mayotte = 32_000_152,
    Mexico = 32_000_153,
    Micronesia = 32_000_154,
    Moldova = 32_000_155,
    Monaco = 32_000_156,
    Mongolia = 32_000_157,
    Montenegro = 32_000_158,
    Montserrat = 32_000_159,
    Morocco = 32_000_160,
    Mozambique = 32_000_161,
    Myanmar = 32_000_162,
    Namibia = 32_000_163,
    Nauru = 32_000_164,
    Nepal = 32_000_165,
    Netherlands = 32_000_166,
    NewCaledonia = 32_000_167,
    NewZealand = 32_000_168,
    Nicaragua = 32_000_169,
    Niger = 32_000_170,
    Nigeria = 32_000_171,
    Niue = 32_000_172,
    NorfolkIsland = 32_000_173,
    NorthKorea = 32_000_174,
    NorthernMarianaIslands = 32_000_175,
    Norway = 32_000_176,
    Oman = 32_000_177,
    Pakistan = 32_000_178,
    Palau = 32_000_179,
    Palestine = 32_000_180,
    Panama = 32_000_181,
    PapuaNewGuinea = 32_000_182,
    Paraguay = 32_000_183,
    Peru = 32_000_184,
    Philippines = 32_000_185,
    PitcairnIslands = 32_000_186,
    Poland = 32_000_187,
    Portugal = 32_000_188,
    PuertoRico = 32_000_189,
    Qatar = 32_000_190,
    Réunion = 32_000_191,
    Romania = 32_000_192,
    Russia = 32_000_193,
    Rwanda = 32_000_194,
    SaintBarthélemy = 32_000_195,
    SaintHelena = 32_000_196,
    SaintKittsAndNevis = 32_000_197,
    SaintLucia = 32_000_198,
    SaintMartin = 32_000_199,
    SaintPierreAndMiquelon = 32_000_200,
    Samoa = 32_000_201,
    SanMarino = 32_000_202,
    SãoToméAndPríncipe = 32_000_203,
    SaudiArabia = 32_000_204,
    Senegal = 32_000_205,
    Serbia = 32_000_206,
    Seychelles = 32_000_207,
    SierraLeone = 32_000_208,
    Singapore = 32_000_209,
    SintMaarten = 32_000_210,
    Slovakia = 32_000_211,
    Slovenia = 32_000_212,
    SolomonIslands = 32_000_213,
    Somalia = 32_000_214,
    SouthAfrica = 32_000_215,
    SouthKorea = 32_000_216,
    SouthSudan = 32_000_217,
    Spain = 32_000_218,
    SriLanka = 32_000_219,
    StVincentAndGrenadines = 32_000_220,
    Sudan = 32_000_221,
    Suriname = 32_000_222,
    SvalbardAndJanMayen = 32_000_223,
    Swaziland = 32_000_224,
    Sweden = 32_000_225,
    Switzerland = 32_000_226,
    Syria = 32_000_227,
    Taiwan = 32_000_228,
    Tajikistan = 32_000_229,
    Tanzania = 32_000_230,
    Thailand = 32_000_231,
    TimorLeste = 32_000_232,
    Togo = 32_000_233,
    Tokelau = 32_000_234,
    Tonga = 32_000_235,
    TrinidadAndTobago = 32_000_236,
    TristanDaCunha = 32_000_237,
    Tunisia = 32_000_238,
    Turkey = 32_000_239,
    Turkmenistan = 32_000_240,
    TurksAndCaicosIslands = 32_000_241,
    Tuvalu = 32_000_242,
    USOutlyingIslands = 32_000_243,
    USVirginIslands = 32_000_244,
    Uganda = 32_000_245,
    Ukraine = 32_000_246,
    UnitedArabEmirates = 32_000_247,
    UnitedKingdom = 32_000_248,
    UnitedStates = 32_000_249,
    Uruguay = 32_000_250,
    Uzbekistan = 32_000_251,
    Vanuatu = 32_000_252,
    VaticanCity = 32_000_253,
    Venezuela = 32_000_254,
    Vietnam = 32_000_255,
    WallisAndFutuna = 32_000_256,
    WesternSahara = 32_000_257,
    Yemen = 32_000_258,
    Zambia = 32_000_259,
    Zimbabwe = 32_000_260,
    DoNotUse1 = 32_000_261,
    DoNotUse2 = 32_000_262,
    DoNotUse3 = 32_000_263,
    DoNotUse4 = 32_000_264,
    DoNotUse5 = 32_000_265,
}

impl std::fmt::Display for Local {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        std::fmt::Debug::fmt(self, f)
    }
}

impl Default for Local {
    fn default() -> Self {
        Self::None
    }
}

impl Local {
    #[must_use]
    pub fn from_i32(num: i32) -> Option<Self> {
        num_traits::FromPrimitive::from_i32(num)
    }

    #[must_use]
    pub fn from_u32(num: u32) -> Option<Self> {
        num_traits::FromPrimitive::from_u32(num)
    }

    #[must_use]
    pub fn from_usize(num: usize) -> Option<Self> {
        num_traits::FromPrimitive::from_usize(num)
    }

    #[must_use]
    pub fn to_i32(&self) -> i32 {
        num_traits::ToPrimitive::to_i32(self).unwrap_or_default()
    }

    #[must_use]
    pub fn to_u32(&self) -> u32 {
        num_traits::ToPrimitive::to_u32(self).unwrap_or_default()
    }

    #[must_use]
    pub fn to_usize(&self) -> usize {
        num_traits::ToPrimitive::to_usize(self).unwrap_or_default()
    }
}