forked from mirror/Riven
1
0
Fork 0

Add #![deny(missing_docs)], document all items

users/mingwei/unknown-variant-messy
Mingwei Samuel 2022-02-08 17:17:47 -08:00
parent 7865a439e1
commit 1d70c479cf
14 changed files with 43 additions and 11 deletions

View File

@ -871,6 +871,11 @@ impl Champion {
}
}
/// The error used for failures in [`Champion`]'s
/// [`FromStr`](std::str::FromStr) implementation.
///
/// Currently only internally stores the four characters used to parse the
/// champion, but may change in the future.
#[derive(Debug)]
pub struct ParseChampionError([char; 4]);
impl std::fmt::Display for ParseChampionError {

View File

@ -17,10 +17,16 @@ use strum_macros::{ EnumString, Display, AsRefStr, IntoStaticStr };
#[derive(IntoPrimitive, TryFromPrimitive)]
#[repr(u8)]
pub enum Division {
/// Division 1, the best/highest division in a [`Tier`](crate::consts::Tier), or the only division in
/// [apex tiers](crate::consts::Tier::is_apex).
I = 1,
/// Division 2, the second highest division.
II = 2,
/// Division 3, the third highest division.
III = 3,
/// Division 4, the fourth and lowest division since 2019.
IV = 4,
/// Division 5, the lowest division, only used before 2019.
#[deprecated(note="Removed for 2019.")]
V = 5,
}

View File

@ -16,7 +16,7 @@ use strum_macros::{ EnumString, IntoStaticStr };
#[derive(EnumString, IntoStaticStr)]
#[repr(u8)]
pub enum GameMode {
// Catch-all variant for new, unknown game modes.
/// Catch-all variant for new, unknown game modes.
#[strum(default)]
UNKNOWN(String),

View File

@ -6,17 +6,17 @@ use strum_macros::{ EnumString, Display, AsRefStr, IntoStaticStr };
#[derive(Eq, PartialEq, Hash)]
#[derive(EnumString, Display, AsRefStr, IntoStaticStr)]
pub enum QueueType {
// League of Legends, Summoner's Rift (5v5), Ranked Solo Queue.
/// League of Legends, Summoner's Rift (5v5), Ranked Solo Queue.
RANKED_SOLO_5x5,
// League of Legends, Summoner's Rift (5v5), Flex Queue.
/// League of Legends, Summoner's Rift (5v5), Flex Queue.
RANKED_FLEX_SR,
// League of Legends, Twisted Treeline (3v3), Flex Queue.
/// League of Legends, Twisted Treeline (3v3), Flex Queue.
RANKED_FLEX_TT,
// Ranked Teamfight Tactics.
/// Ranked Teamfight Tactics.
RANKED_TFT,
// Ranked Teamfight Tactics, Hyper Roll gamemode.
/// Ranked Teamfight Tactics, Hyper Roll gamemode.
RANKED_TFT_TURBO,
// Ranked Teamfight Tactics, Double Up gamemode.
/// Ranked Teamfight Tactics, Double Up gamemode.
RANKED_TFT_PAIRS
}

View File

@ -82,6 +82,8 @@ pub enum PlatformRoute {
}
impl PlatformRoute {
/// Converts this [`PlatformRoute`] into its corresponding
/// [`RegionalRoute`]. Useful, for example, in [`match-v5` endpoints](crate::endpoints::MatchV5).
pub fn to_regional(self) -> RegionalRoute {
match self {
Self::BR1 => RegionalRoute::AMERICAS,
@ -160,8 +162,11 @@ pub enum ValPlatformRoute {
#[repr(u8)]
#[non_exhaustive]
pub enum Route {
/// Sub-variant for [`RegionalRoute`]s.
Regional(RegionalRoute),
/// Sub-variant for [`PlatformRoute`]s.
Platform(PlatformRoute),
/// Sub-variant for [`ValPlatformRoute`]s.
ValPlatform(ValPlatformRoute),
}
@ -232,6 +237,8 @@ impl std::str::FromStr for Route {
}
impl Route {
/// Returns an iterator over all routes. Starts with [`Self::Regional`],
/// then [`Self::Platform`], and finally [`Self::ValPlatform`].
pub fn iter() -> impl Iterator<Item = Self> {
use strum::IntoEnumIterator;

View File

@ -41,8 +41,8 @@ pub enum Tier {
serde_string!(Tier);
impl Tier {
/// If this tier is an apex tier: master, grandmaster, or challenger.
/// Returns false for unranked.
/// If this tier is an apex tier: [`Self::MASTER`], [`Self::GRANDMASTER`],
/// or [`Self::CHALLENGER`]. Returns false for [`Self::UNRANKED`].
///
/// These tiers are NOT queryable by LeagueV4Endpoints::get_league_entries(...).
pub const fn is_apex(self) -> bool {
@ -53,7 +53,7 @@ impl Tier {
/// If this tier is a "standard" tier: iron through diamond.
/// Returns false for unranked.
///
/// ONLY these tiers are queryable by LeagueV4Endpoints::get_league_entries(...).
/// ONLY these tiers are queryable by [`LeagueV4::get_league_entries(...)`](crate::endpoints::LeagueV4::get_league_entries).
pub fn is_standard(self) -> bool {
// Casts needed for const.
((Self::UNRANKED as u8) < (self as u8)) && ((self as u8) < (Self::MASTER as u8))

View File

@ -7,6 +7,7 @@
///////////////////////////////////////////////
#![forbid(unsafe_code)]
#![deny(missing_docs)]
//! <h1 align="center">
//! Riven<br>

View File

@ -13,6 +13,8 @@
//!
//! Note: this modules is automatically generated.
/// Metadata for endpoints. Each tuple corresponds to one endpoint and contains
/// the HTTP [`Method`](reqwest::Method), `str` path, and the method's `str` ID.
pub static ALL_ENDPOINTS: [(reqwest::Method, &str, &str); 70] = [
(reqwest::Method::GET, "/riot/account/v1/accounts/by-puuid/{puuid}", "account-v1.getByPuuid"),
(reqwest::Method::GET, "/riot/account/v1/accounts/by-riot-id/{gameName}/{tagLine}", "account-v1.getByRiotId"),

View File

@ -9,6 +9,8 @@
// http://www.mingweisamuel.com/riotapi-schema/tool/
// Version be7cba85eef6d2262d61d1befff94fe2d6628d8e
#![allow(missing_docs)]
//! Data transfer structs.
//!
//! Separated into separate modules for each endpoint.

View File

@ -107,6 +107,10 @@ impl Champion {
}
}
/// The error used for failures in [`Champion::from_str`].
///
/// Currently only internally stores the four characters used to parse the
/// champion, but may change in the future.
#[derive(Debug)]
pub struct ParseChampionError([char; 4]);
impl std::fmt::Display for ParseChampionError {

View File

@ -13,7 +13,7 @@ use strum_macros::{ EnumString, IntoStaticStr };
#[derive(EnumString, IntoStaticStr)]
#[repr(u8)]
pub enum GameMode {
// Catch-all variant for new, unknown game modes.
/// Catch-all variant for new, unknown game modes.
#[strum(default)]
UNKNOWN(String),

View File

@ -4,6 +4,7 @@
}}{{= dotUtils.preamble() }}
#![forbid(unsafe_code)]
#![deny(missing_docs)]
{{~ readme :line }}
//! {{= line }}

View File

@ -18,6 +18,8 @@
//!
//! Note: this modules is automatically generated.
/// Metadata for endpoints. Each tuple corresponds to one endpoint and contains
/// the HTTP [`Method`](reqwest::Method), `str` path, and the method's `str` ID.
pub static ALL_ENDPOINTS: [(reqwest::Method, &str, &str); {{= operations.length }}] = [
{{
for (const { route, method, operation } of operations) {

View File

@ -6,6 +6,8 @@
// http://www.mingweisamuel.com/riotapi-schema/tool/
// Version {{= spec.info.version }}
#![allow(missing_docs)]
//! Data transfer structs.
//!
//! Separated into separate modules for each endpoint.