mirror of https://github.com/MingweiSamuel/Riven
Add division enum, update enums with strum macros, serde_repr
parent
42c6801453
commit
44b12c2f32
|
@ -18,6 +18,9 @@ parking_lot = { version = "0.9", features = [ "nightly" ] }
|
||||||
reqwest = { version = "0.10.0-alpha.1", features = [ "gzip", "json" ] }
|
reqwest = { version = "0.10.0-alpha.1", features = [ "gzip", "json" ] }
|
||||||
scan_fmt = "0.2"
|
scan_fmt = "0.2"
|
||||||
serde = { version = "1.0", features = [ "derive" ] }
|
serde = { version = "1.0", features = [ "derive" ] }
|
||||||
|
serde_repr = "0.1"
|
||||||
|
strum = "0.16"
|
||||||
|
strum_macros = "0.16"
|
||||||
tokio-timer = "0.3.0-alpha.5"
|
tokio-timer = "0.3.0-alpha.5"
|
||||||
url = "2.1"
|
url = "2.1"
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
#![allow(deprecated)]
|
||||||
|
|
||||||
|
use std::fmt::Debug;
|
||||||
|
|
||||||
|
use strum_macros::{ EnumString, Display, AsRefStr };
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
#[derive(Eq, PartialEq, Hash, PartialOrd, Ord)]
|
||||||
|
#[derive(EnumString, Display, AsRefStr)]
|
||||||
|
#[repr(u8)]
|
||||||
|
pub enum Division {
|
||||||
|
I = 1,
|
||||||
|
II = 2,
|
||||||
|
III = 3,
|
||||||
|
IV = 4,
|
||||||
|
|
||||||
|
#[deprecated(note="Removed for 2019.")]
|
||||||
|
V = 5,
|
||||||
|
}
|
|
@ -1,19 +1,22 @@
|
||||||
//! Constant data and Enums relevant to the Riot Games API.
|
//! Constant data and Enums relevant to the Riot Games API.
|
||||||
|
|
||||||
mod region;
|
|
||||||
pub use region::*;
|
|
||||||
|
|
||||||
mod champion;
|
mod champion;
|
||||||
pub use champion::*;
|
pub use champion::*;
|
||||||
|
|
||||||
mod season;
|
mod division;
|
||||||
pub use season::*;
|
pub use division::*;
|
||||||
|
|
||||||
mod queue;
|
|
||||||
pub use queue::*;
|
|
||||||
|
|
||||||
mod queue_type;
|
mod queue_type;
|
||||||
pub use queue_type::*;
|
pub use queue_type::*;
|
||||||
|
|
||||||
|
mod queue;
|
||||||
|
pub use queue::*;
|
||||||
|
|
||||||
|
mod region;
|
||||||
|
pub use region::*;
|
||||||
|
|
||||||
|
mod season;
|
||||||
|
pub use season::*;
|
||||||
|
|
||||||
mod team;
|
mod team;
|
||||||
pub use team::*;
|
pub use team::*;
|
||||||
|
|
|
@ -1,7 +1,14 @@
|
||||||
// This file is automatically generated.
|
// This file is automatically generated.
|
||||||
// Do not directly edit.
|
// Do not directly edit.
|
||||||
|
#![allow(deprecated)]
|
||||||
|
|
||||||
|
use serde_repr::{ Serialize_repr, Deserialize_repr };
|
||||||
|
|
||||||
/// League of Legends matchmaking queue.
|
/// League of Legends matchmaking queue.
|
||||||
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
#[derive(Eq, PartialEq)]
|
||||||
|
#[derive(Serialize_repr, Deserialize_repr)]
|
||||||
|
#[repr(u16)]
|
||||||
pub enum Queue {
|
pub enum Queue {
|
||||||
|
|
||||||
/// Custom games.
|
/// Custom games.
|
||||||
|
|
|
@ -1,28 +1,41 @@
|
||||||
use std::fmt;
|
use std::fmt::Debug;
|
||||||
|
|
||||||
#[derive(fmt::Debug, Copy, Clone)]
|
use strum_macros::{ EnumString, Display, AsRefStr };
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
#[derive(Eq, PartialEq, Hash)]
|
||||||
|
#[derive(EnumString, Display, AsRefStr)]
|
||||||
pub enum QueueType {
|
pub enum QueueType {
|
||||||
// League of Legends, Summoner's Rift (5v5), Ranked Solo Queue.
|
// League of Legends, Summoner's Rift (5v5), Ranked Solo Queue.
|
||||||
|
#[strum(to_string="RANKED_SOLO_5x5")]
|
||||||
RankedSolo5x5,
|
RankedSolo5x5,
|
||||||
// League of Legends, Summoner's Rift (5v5), Flex Queue.
|
// League of Legends, Summoner's Rift (5v5), Flex Queue.
|
||||||
|
#[strum(to_string="RANKED_FLEX_SR")]
|
||||||
RankedFlexSr,
|
RankedFlexSr,
|
||||||
// League of Legends, Twisted Treeline (3v3), Flex Queue.
|
// League of Legends, Twisted Treeline (3v3), Flex Queue.
|
||||||
|
#[strum(to_string="RANKED_FLEX_TT")]
|
||||||
RankedFlexTt,
|
RankedFlexTt,
|
||||||
// Ranked Teamfight Tactics.
|
// Ranked Teamfight Tactics.
|
||||||
|
#[strum(to_string="RANKED_TFT")]
|
||||||
RankedTft,
|
RankedTft,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl QueueType {
|
#[cfg(test)]
|
||||||
const NAMES: [&'static str; 4] = [
|
mod test {
|
||||||
"RANKED_SOLO_5x5",
|
use super::*;
|
||||||
"RANKED_FLEX_SR",
|
|
||||||
"RANKED_FLEX_TT",
|
|
||||||
"RANKED_TFT",
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Display for QueueType {
|
#[test]
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn check_as_ref() {
|
||||||
write!(f, "{}", Self::NAMES[*self as usize])
|
assert_eq!("RANKED_SOLO_5x5", QueueType::RankedSolo5x5.as_ref());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn check_to_string() {
|
||||||
|
assert_eq!("RANKED_SOLO_5x5", QueueType::RankedSolo5x5.to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn check_from_string() {
|
||||||
|
assert_eq!(Some(QueueType::RankedSolo5x5), "RANKED_SOLO_5x5".parse().ok());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,15 @@
|
||||||
return name;
|
return name;
|
||||||
});
|
});
|
||||||
}}{{= dotUtils.preamble() }}
|
}}{{= dotUtils.preamble() }}
|
||||||
|
#![allow(deprecated)]
|
||||||
|
|
||||||
|
use serde_repr::{ Serialize_repr, Deserialize_repr };
|
||||||
|
|
||||||
/// League of Legends matchmaking queue.
|
/// League of Legends matchmaking queue.
|
||||||
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
#[derive(Eq, PartialEq)]
|
||||||
|
#[derive(Serialize_repr, Deserialize_repr)]
|
||||||
|
#[repr(u16)]
|
||||||
pub enum Queue {
|
pub enum Queue {
|
||||||
{{
|
{{
|
||||||
for (let [ groupName, colQueues ] of groupedQueues) {
|
for (let [ groupName, colQueues ] of groupedQueues) {
|
||||||
|
|
Loading…
Reference in New Issue