1
0
Fork 1
mirror of https://github.com/MingweiSamuel/Riven.git synced 2025-03-30 02:23:16 -07:00
Riven/src/consts/region.rs
2019-11-04 17:00:59 -08:00

58 lines
No EOL
1.6 KiB
Rust

use strum_macros::{ EnumString, Display, AsRefStr, IntoStaticStr };
/// A region served by a single game server.
/// Each Riot Games API request is directed at a particular region,
/// with tournament API requests directed at the AMERICAS "global" region.
#[derive(Debug)]
#[derive(PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(EnumString, Display, AsRefStr, IntoStaticStr)]
#[derive(Clone, Copy)]
pub enum Region {
#[strum(to_string="BR1", serialize="BR")]
BR,
#[strum(to_string="EUN1", serialize="EUNE")]
EUNE,
#[strum(to_string="EUW1", serialize="EUW")]
EUW,
#[strum(to_string="NA1", serialize="NA")]
NA,
#[strum(to_string="KR", serialize="KR")]
KR,
#[strum(to_string="LA1", serialize="LAN")]
LAN,
#[strum(to_string="LA2", serialize="LAS")]
LAS,
#[strum(to_string="OC1", serialize="OCE")]
OCE,
#[strum(to_string="RU", serialize="RU")]
RU,
#[strum(to_string="TR1", serialize="TR")]
TR,
#[strum(to_string="JP1", serialize="JP")]
JP,
#[strum(to_string="PBE1", serialize="PBE")]
PBE,
#[strum(to_string="AMERICAS", serialize="AMERICAS")]
AMERICAS,
#[strum(to_string="EUROPE", serialize="EUROPE")]
EUROPE,
#[strum(to_string="ASIA", serialize="ASIA")]
ASIA,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_basic() {
assert_eq!("BR1", Region::BR.to_string());
}
#[test]
fn test_get() {
assert_eq!(Ok(Region::JP), "JP".parse());
assert_eq!(Ok(Region::NA), "NA1".parse());
assert!("LA".parse::<Region>().is_err());
}
}