mirror of
https://github.com/MingweiSamuel/Riven.git
synced 2024-12-25 10:26:31 +00:00
Add rustfmt.toml
This commit is contained in:
parent
33ef298039
commit
8d810ccca8
25 changed files with 39 additions and 76 deletions
|
@ -4,14 +4,12 @@ use std::convert::Infallible;
|
||||||
|
|
||||||
use http::{Method, Request, Response, StatusCode};
|
use http::{Method, Request, Response, StatusCode};
|
||||||
use hyper::header::HeaderValue;
|
use hyper::header::HeaderValue;
|
||||||
use hyper::http;
|
|
||||||
use hyper::service::{make_service_fn, service_fn};
|
use hyper::service::{make_service_fn, service_fn};
|
||||||
use hyper::{Body, Server};
|
use hyper::{http, Body, Server};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use tracing as log;
|
|
||||||
|
|
||||||
use riven::consts::Route;
|
use riven::consts::Route;
|
||||||
use riven::{RiotApi, RiotApiConfig};
|
use riven::{RiotApi, RiotApiConfig};
|
||||||
|
use tracing as log;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
/// Create lazy static RiotApi instance.
|
/// Create lazy static RiotApi instance.
|
||||||
|
|
|
@ -5,8 +5,6 @@ use reqwest::header::{HeaderMap, HeaderValue};
|
||||||
use reqwest::ClientBuilder;
|
use reqwest::ClientBuilder;
|
||||||
|
|
||||||
/// Configuration for instantiating RiotApi.
|
/// Configuration for instantiating RiotApi.
|
||||||
///
|
|
||||||
///
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct RiotApiConfig {
|
pub struct RiotApiConfig {
|
||||||
pub(crate) base_url: String,
|
pub(crate) base_url: String,
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
///
|
///
|
||||||
/// Also implements `AsRef<str>`, `Display`, and `From<&str>`.
|
/// Also implements `AsRef<str>`, `Display`, and `From<&str>`.
|
||||||
macro_rules! serde_strum_unknown {
|
macro_rules! serde_strum_unknown {
|
||||||
( $name:ident ) => {
|
($name:ident) => {
|
||||||
impl AsRef<str> for $name {
|
impl AsRef<str> for $name {
|
||||||
fn as_ref(&self) -> &str {
|
fn as_ref(&self) -> &str {
|
||||||
match self {
|
match self {
|
||||||
|
|
|
@ -47,11 +47,8 @@ pub use route_ext::*;
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
mod season;
|
mod season;
|
||||||
pub use season::*;
|
pub use season::*;
|
||||||
|
|
||||||
/// Trait allowing iteration of enum types, implemented by several enums in this module.
|
/// Trait allowing iteration of enum types, implemented by several enums in this module.
|
||||||
/// Re-exported from strum.
|
/// Re-exported from strum.
|
||||||
///
|
|
||||||
///
|
|
||||||
pub use strum::IntoEnumIterator;
|
pub use strum::IntoEnumIterator;
|
||||||
|
|
||||||
mod team;
|
mod team;
|
||||||
|
|
|
@ -4,9 +4,9 @@ mod rate_limit;
|
||||||
pub use rate_limit::*;
|
pub use rate_limit::*;
|
||||||
|
|
||||||
mod rate_limit_type;
|
mod rate_limit_type;
|
||||||
pub use rate_limit_type::*;
|
use std::time::Instant;
|
||||||
|
|
||||||
use std::time::Instant; // Hack for token_bucket_test.rs.
|
pub use rate_limit_type::*; // Hack for token_bucket_test.rs.
|
||||||
mod token_bucket;
|
mod token_bucket;
|
||||||
pub use token_bucket::*;
|
pub use token_bucket::*;
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
#[cfg(feature = "tracing")]
|
|
||||||
use tracing as log;
|
|
||||||
|
|
||||||
use parking_lot::{RwLock, RwLockUpgradableReadGuard};
|
use parking_lot::{RwLock, RwLockUpgradableReadGuard};
|
||||||
use reqwest::{Response, StatusCode};
|
use reqwest::{Response, StatusCode};
|
||||||
use scan_fmt::scan_fmt;
|
use scan_fmt::scan_fmt;
|
||||||
use tokio::sync::Notify;
|
use tokio::sync::Notify;
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
|
use tracing as log;
|
||||||
|
|
||||||
use super::RateLimitType;
|
use super::{RateLimitType, TokenBucket, VectorTokenBucket};
|
||||||
use super::{TokenBucket, VectorTokenBucket};
|
|
||||||
use crate::RiotApiConfig;
|
use crate::RiotApiConfig;
|
||||||
|
|
||||||
pub struct RateLimit {
|
pub struct RateLimit {
|
||||||
|
|
|
@ -1,21 +1,15 @@
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use reqwest::{RequestBuilder, StatusCode};
|
||||||
#[cfg(feature = "tracing")]
|
#[cfg(feature = "tracing")]
|
||||||
use tracing as log;
|
use tracing as log;
|
||||||
#[cfg(feature = "tracing")]
|
#[cfg(feature = "tracing")]
|
||||||
use tracing::Instrument;
|
use tracing::Instrument;
|
||||||
|
|
||||||
use reqwest::{RequestBuilder, StatusCode};
|
use super::{RateLimit, RateLimitType};
|
||||||
|
|
||||||
use crate::util::InsertOnlyCHashMap;
|
use crate::util::InsertOnlyCHashMap;
|
||||||
use crate::ResponseInfo;
|
use crate::{ResponseInfo, Result, RiotApiConfig, RiotApiError};
|
||||||
use crate::Result;
|
|
||||||
use crate::RiotApiConfig;
|
|
||||||
use crate::RiotApiError;
|
|
||||||
|
|
||||||
use super::RateLimit;
|
|
||||||
use super::RateLimitType;
|
|
||||||
|
|
||||||
pub struct RegionalRequester {
|
pub struct RegionalRequester {
|
||||||
/// The app rate limit.
|
/// The app rate limit.
|
||||||
|
|
|
@ -7,9 +7,10 @@ mod token_bucket {
|
||||||
include!("token_bucket.rs");
|
include!("token_bucket.rs");
|
||||||
|
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref ZERO: Duration = Duration::new(0, 0);
|
pub static ref ZERO: Duration = Duration::new(0, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,13 @@
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use reqwest::{Client, Method, RequestBuilder};
|
||||||
#[cfg(feature = "tracing")]
|
#[cfg(feature = "tracing")]
|
||||||
use tracing as log;
|
use tracing as log;
|
||||||
|
|
||||||
use reqwest::{Client, Method, RequestBuilder};
|
|
||||||
|
|
||||||
use crate::req::RegionalRequester;
|
use crate::req::RegionalRequester;
|
||||||
use crate::util::InsertOnlyCHashMap;
|
use crate::util::InsertOnlyCHashMap;
|
||||||
use crate::ResponseInfo;
|
use crate::{ResponseInfo, Result, RiotApiConfig, RiotApiError};
|
||||||
use crate::Result;
|
|
||||||
use crate::RiotApiConfig;
|
|
||||||
use crate::RiotApiError;
|
|
||||||
|
|
||||||
/// For retrieving data from the Riot Games API.
|
/// For retrieving data from the Riot Games API.
|
||||||
///
|
///
|
||||||
|
|
|
@ -3,11 +3,9 @@
|
||||||
|
|
||||||
mod async_tests;
|
mod async_tests;
|
||||||
mod testutils;
|
mod testutils;
|
||||||
use testutils::*;
|
|
||||||
|
|
||||||
use colored::*;
|
use colored::*;
|
||||||
|
|
||||||
use riven::consts::*;
|
use riven::consts::*;
|
||||||
|
use testutils::*;
|
||||||
|
|
||||||
const ROUTE: PlatformRoute = PlatformRoute::RU;
|
const ROUTE: PlatformRoute = PlatformRoute::RU;
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,10 @@
|
||||||
|
|
||||||
mod async_tests;
|
mod async_tests;
|
||||||
mod testutils;
|
mod testutils;
|
||||||
use testutils::*;
|
|
||||||
|
|
||||||
use colored::*;
|
use colored::*;
|
||||||
|
|
||||||
use riven::consts::*;
|
use riven::consts::*;
|
||||||
use riven::models::tournament_stub_v5::*;
|
use riven::models::tournament_stub_v5::*;
|
||||||
|
use testutils::*;
|
||||||
|
|
||||||
const ROUTE: RegionalRoute = RegionalRoute::AMERICAS;
|
const ROUTE: RegionalRoute = RegionalRoute::AMERICAS;
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,9 @@
|
||||||
|
|
||||||
mod async_tests;
|
mod async_tests;
|
||||||
mod testutils;
|
mod testutils;
|
||||||
use testutils::*;
|
|
||||||
|
|
||||||
use colored::*;
|
use colored::*;
|
||||||
|
|
||||||
use riven::consts::*;
|
use riven::consts::*;
|
||||||
|
use testutils::*;
|
||||||
|
|
||||||
const ROUTE: PlatformRoute = PlatformRoute::JP1;
|
const ROUTE: PlatformRoute = PlatformRoute::JP1;
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,9 @@
|
||||||
|
|
||||||
mod async_tests;
|
mod async_tests;
|
||||||
mod testutils;
|
mod testutils;
|
||||||
use testutils::*;
|
|
||||||
|
|
||||||
use colored::*;
|
use colored::*;
|
||||||
|
|
||||||
use riven::consts::*;
|
use riven::consts::*;
|
||||||
|
use testutils::*;
|
||||||
|
|
||||||
const ROUTE: RegionalRoute = RegionalRoute::EUROPE;
|
const ROUTE: RegionalRoute = RegionalRoute::EUROPE;
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,9 @@
|
||||||
|
|
||||||
mod async_tests;
|
mod async_tests;
|
||||||
mod testutils;
|
mod testutils;
|
||||||
use testutils::*;
|
|
||||||
|
|
||||||
use colored::*;
|
use colored::*;
|
||||||
|
|
||||||
use riven::consts::*;
|
use riven::consts::*;
|
||||||
|
use testutils::*;
|
||||||
|
|
||||||
const ROUTE: PlatformRoute = PlatformRoute::EUW1;
|
const ROUTE: PlatformRoute = PlatformRoute::EUW1;
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,9 @@
|
||||||
|
|
||||||
mod async_tests;
|
mod async_tests;
|
||||||
mod testutils;
|
mod testutils;
|
||||||
use testutils::*;
|
|
||||||
|
|
||||||
use colored::*;
|
use colored::*;
|
||||||
|
|
||||||
use riven::consts::*;
|
use riven::consts::*;
|
||||||
|
use testutils::*;
|
||||||
|
|
||||||
const ROUTE: PlatformRoute = PlatformRoute::EUW1;
|
const ROUTE: PlatformRoute = PlatformRoute::EUW1;
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,9 @@
|
||||||
|
|
||||||
mod async_tests;
|
mod async_tests;
|
||||||
mod testutils;
|
mod testutils;
|
||||||
use testutils::RIOT_API;
|
|
||||||
|
|
||||||
use colored::*;
|
use colored::*;
|
||||||
|
|
||||||
use riven::consts::*;
|
use riven::consts::*;
|
||||||
|
use testutils::RIOT_API;
|
||||||
|
|
||||||
const ROUTE: PlatformRoute = PlatformRoute::LA1;
|
const ROUTE: PlatformRoute = PlatformRoute::LA1;
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,10 @@
|
||||||
|
|
||||||
mod async_tests;
|
mod async_tests;
|
||||||
mod testutils;
|
mod testutils;
|
||||||
use testutils::*;
|
|
||||||
|
|
||||||
use colored::*;
|
use colored::*;
|
||||||
|
|
||||||
use riven::consts::*;
|
use riven::consts::*;
|
||||||
use riven::models::summoner_v4::*;
|
use riven::models::summoner_v4::*;
|
||||||
|
use testutils::*;
|
||||||
|
|
||||||
fn validate_summoners(s1: Summoner, s2: Summoner) -> Result<(), String> {
|
fn validate_summoners(s1: Summoner, s2: Summoner) -> Result<(), String> {
|
||||||
rassert_eq!(s1.name, s2.name, "Names didn't match {}.", "");
|
rassert_eq!(s1.name, s2.name, "Names didn't match {}.", "");
|
||||||
|
|
|
@ -3,11 +3,9 @@
|
||||||
|
|
||||||
mod async_tests;
|
mod async_tests;
|
||||||
mod testutils;
|
mod testutils;
|
||||||
use testutils::*;
|
|
||||||
|
|
||||||
use colored::*;
|
use colored::*;
|
||||||
|
|
||||||
use riven::consts::*;
|
use riven::consts::*;
|
||||||
|
use testutils::*;
|
||||||
|
|
||||||
const ROUTE: PlatformRoute = PlatformRoute::PH2;
|
const ROUTE: PlatformRoute = PlatformRoute::PH2;
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,9 @@
|
||||||
|
|
||||||
mod async_tests;
|
mod async_tests;
|
||||||
mod testutils;
|
mod testutils;
|
||||||
use testutils::*;
|
|
||||||
|
|
||||||
use colored::*;
|
use colored::*;
|
||||||
|
|
||||||
use riven::consts::*;
|
use riven::consts::*;
|
||||||
|
use testutils::*;
|
||||||
|
|
||||||
const ROUTE: PlatformRoute = PlatformRoute::SG2;
|
const ROUTE: PlatformRoute = PlatformRoute::SG2;
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,9 @@
|
||||||
|
|
||||||
mod async_tests;
|
mod async_tests;
|
||||||
mod testutils;
|
mod testutils;
|
||||||
use testutils::*;
|
|
||||||
|
|
||||||
use colored::*;
|
use colored::*;
|
||||||
|
|
||||||
use riven::consts::*;
|
use riven::consts::*;
|
||||||
|
use testutils::*;
|
||||||
|
|
||||||
const ROUTE: PlatformRoute = PlatformRoute::TH2;
|
const ROUTE: PlatformRoute = PlatformRoute::TH2;
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,10 @@
|
||||||
|
|
||||||
mod async_tests;
|
mod async_tests;
|
||||||
mod testutils;
|
mod testutils;
|
||||||
use testutils::RIOT_API;
|
|
||||||
|
|
||||||
use colored::*;
|
use colored::*;
|
||||||
|
|
||||||
use riven::consts::*;
|
use riven::consts::*;
|
||||||
use riven::models::summoner_v4::Summoner;
|
use riven::models::summoner_v4::Summoner;
|
||||||
|
use testutils::RIOT_API;
|
||||||
|
|
||||||
const ROUTE: PlatformRoute = PlatformRoute::TR1;
|
const ROUTE: PlatformRoute = PlatformRoute::TR1;
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,9 @@
|
||||||
|
|
||||||
mod async_tests;
|
mod async_tests;
|
||||||
mod testutils;
|
mod testutils;
|
||||||
use testutils::RIOT_API;
|
|
||||||
|
|
||||||
use colored::*;
|
use colored::*;
|
||||||
|
|
||||||
use riven::consts::*;
|
use riven::consts::*;
|
||||||
|
use testutils::RIOT_API;
|
||||||
|
|
||||||
const ROUTE: ValPlatformRoute = ValPlatformRoute::LATAM;
|
const ROUTE: ValPlatformRoute = ValPlatformRoute::LATAM;
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,9 @@
|
||||||
|
|
||||||
mod async_tests;
|
mod async_tests;
|
||||||
mod testutils;
|
mod testutils;
|
||||||
use testutils::*;
|
|
||||||
|
|
||||||
use colored::*;
|
use colored::*;
|
||||||
|
|
||||||
use riven::consts::*;
|
use riven::consts::*;
|
||||||
|
use testutils::*;
|
||||||
|
|
||||||
const ROUTE: PlatformRoute = PlatformRoute::VN2;
|
const ROUTE: PlatformRoute = PlatformRoute::VN2;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
|
||||||
use riven::consts::{PlatformRoute, QueueType, RegionalRoute};
|
use riven::consts::{PlatformRoute, QueueType, RegionalRoute};
|
||||||
use riven::{RiotApi, RiotApiConfig};
|
use riven::{RiotApi, RiotApiConfig};
|
||||||
|
|
||||||
|
|
10
rustfmt.toml
Normal file
10
rustfmt.toml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
format_code_in_doc_comments = true
|
||||||
|
format_macro_matchers = true
|
||||||
|
group_imports = "StdExternalCrate"
|
||||||
|
hex_literal_case = "Lower"
|
||||||
|
imports_granularity = "Module"
|
||||||
|
newline_style = "Unix"
|
||||||
|
normalize_comments = true
|
||||||
|
normalize_doc_attributes = true
|
||||||
|
use_field_init_shorthand = true
|
||||||
|
use_try_shorthand = true
|
Loading…
Reference in a new issue