1
0
Fork 1
mirror of https://github.com/MingweiSamuel/Riven.git synced 2025-04-11 08:23:16 -07:00

fix & test docs, cleanup CI, cleanup Cargo.toml, regen ()

- Set `RUST_BACKTRACE = "full"`, `RUST_LOG = "info,riven=debug"` in
`.cargo/config.toml` instead of everywhere
- Remove unmaintained `actions-rs` from CI
- Use `#[doc = include_str!(...)]` for including README.md in lib.rs,
instead of awkward codegen
- Update README.md features: `metrics`, clarify `log`/`tracing`,
development testing note
- `Cargo.toml` add `[target.'cfg(docsrs_deps)'.dependencies]` for
doc-linked deps.
- `Cargo.toml` do not include example proxy in publish
- Cleanup `.vscode/settings.json`
- Regen for `crate::consts::TournamentRegion` back in use
This commit is contained in:
Mingwei Samuel 2025-03-18 16:31:14 -07:00 committed by GitHub
parent 7630f02c30
commit 88fd078b3d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 173 additions and 472 deletions

3
.cargo/config.toml Normal file
View file

@ -0,0 +1,3 @@
[env]
RUST_BACKTRACE = "full"
RUST_LOG = "info,riven=debug"

View file

@ -31,67 +31,19 @@ jobs:
needs: pre_job
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
env:
RGAPI_KEY: ${{ secrets.RGAPI_KEY }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
# - name: Setup Node
# uses: actions/setup-node@v4
# with:
# node-version: 20
# - name: Install Node dependencies
# run: npm ci --prefix riven/srcgen
# - name: Run codegen
# run: node riven/srcgen
- name: Install Rust nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: rustfmt
- uses: actions-rs/cargo@v1
with:
toolchain: stable
command: check
args: --all-targets --features __proxy
- uses: actions-rs/cargo@v1
with:
toolchain: stable
command: check
args: --all-targets --features tracing,__proxy
- uses: actions-rs/cargo@v1
with:
command: check
args: --all-targets --features nightly,tracing,__proxy
- uses: actions-rs/cargo@v1
with:
command: build
args: --all-targets --features nightly,deny-unknown,eserde,__proxy
- uses: actions-rs/cargo@v1
with:
command: test
args: --no-fail-fast --features nightly,deny-unknown,eserde,__proxy
env:
RUST_BACKTRACE: 1
RUST_LOG: riven=debug
RGAPI_KEY: ${{ secrets.RGAPI_KEY }}
- uses: actions/checkout@v4
- run: cargo +stable check --all-targets --features riven/__proxy
- run: cargo +stable check --all-targets --features riven/tracing,riven/__proxy
- run: cargo check --all-targets --features riven/nightly,riven/tracing,riven/__proxy
- run: cargo build --all-targets --features riven/nightly,riven/deny-unknown,riven/eserde,riven/__proxy
- run: cargo test --no-fail-fast --features riven/nightly,riven/deny-unknown,riven/eserde,riven/__proxy
- name: Install `wasm-pack`
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- working-directory: riven
run: wasm-pack test --node -- --features nightly,deny-unknown,eserde
env:
RGAPI_KEY: ${{ secrets.RGAPI_KEY }}
- run: wasm-pack test --node -- --features nightly,deny-unknown,eserde
working-directory: riven
lints:
name: Lints
@ -99,28 +51,23 @@ jobs:
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: rustfmt, clippy
- uses: actions/checkout@v4
- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
run: cargo fmt --all -- --check
- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-features --all-targets -- -D warnings
run: cargo clippy --all-features --all-targets -- -D warnings
doc:
name: Docs
needs: pre_job
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
env:
RUSTDOCFLAGS: -Dwarnings
steps:
- uses: actions/checkout@v4
- uses: dtolnay/install@cargo-docs-rs
- run: cargo docs-rs -p riven
msrv:
name: Verify MSRV
@ -128,16 +75,6 @@ jobs:
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install Rust nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: rustfmt
- uses: actions/checkout@v4
- run: cargo install cargo-msrv --no-default-features
- run: cargo msrv verify --path riven

17
.vscode/settings.json vendored
View file

@ -1,18 +1,9 @@
{
"rust-analyzer.runnableEnv": [
{
// Set output levels for `tracing` logging.
"env": {
"RUST_BACKTRACE": "1",
"RUST_LOG": "info,riven=debug"
}
}
],
"rust-analyzer.cargo.features": [
"nightly",
"tracing",
"deny-unknown",
"eserde",
"riven/nightly",
"riven/tracing",
"riven/deny-unknown",
"riven/eserde",
],
"evenBetterToml.formatter.compactArrays": false,
"evenBetterToml.formatter.columnWidth": 100

View file

@ -104,10 +104,17 @@ and specifying the `rustls-tls` feature:
riven = { version = "...", default-features = false, features = [ "rustls-tls" ] }
```
### `log` or `tracing`
### `tracing` (or `log`)
Riven is additionally able to produce [tracing](https://docs.rs/tracing) spans for requests if the `tracing` feature is enabled.
By default the `tracing` feature is disabled and Riven instead writes to [`log`](https://docs.rs/log).
By default Riven logs some diagnostic information using [`log`](https://docs.rs/log).
If the `tracing` feature is enabled, Riven will use [tracing](https://docs.rs/tracing) which
usefully aguments logs with per-request span information.
### `metrics`
The `metrics` feature enables some rudiementary metrics collecting via the [`metrics`](https://docs.rs/metrics)
crate. See [#76](https://github.com/MingweiSamuel/Riven/pull/76) for details. More metrics may be
added in the future.
## Docs
@ -176,3 +183,8 @@ To set up the srcgen, you will first need to install NodeJS. Then enter the
dependencies.
To run the srcgen use `node riven/srcgen` from the repository root.
## Testing
To run tests put your API key into either the `RGAPI_KEY` environment variable or the `apikey.txt`
file.

View file

@ -8,7 +8,7 @@ readme = "../README.md"
license = "MIT"
edition = "2018"
rust-version = "1.71.1"
include = [ "src/**", "../README.md", "/examples" ]
include = [ "/src/**", "/../README.md" ]
keywords = [ "riot-games", "riot", "league", "league-of-legends" ]
categories = [ "api-bindings", "web-programming::http-client", "wasm" ]
@ -16,7 +16,7 @@ categories = [ "api-bindings", "web-programming::http-client", "wasm" ]
crate-type = [ "cdylib", "rlib" ]
[package.metadata.docs.rs]
features = [ "nightly" ]
rustc-args = [ "--cfg=docsrs_deps" ]
[features]
default = [ "default-tls" ]
@ -46,6 +46,7 @@ deny-unknown-enum-variants-strings = [ ]
# If enabled, unknown integer enum variants will cause an error.
deny-unknown-enum-variants-integers = [ ]
# Required for the proxy example.
__proxy = [ ]
[[example]]
@ -93,3 +94,8 @@ console_error_panic_hook = "0.1"
console_log = "1.0"
wasm-bindgen = "0.2.70"
wasm-bindgen-test = "0.3"
[target.'cfg(docsrs_deps)'.dependencies]
eserde = { version = "0.1.6", features = [ "json" ] }
gloo-timers = { version = "0.3", features = [ "futures" ] }
web-time = "1.0.0"

View file

@ -11,21 +11,22 @@ with bodies, however it does not handle RSO endpoints which require an
failure information. Rate limits are enforced, so requests will wait to complete
when Riven is at the rate limit.
Set `RGAPI_KEY` env var then run:
Put your API key into either the `RGAPI_KEY` environment variable or the `apikey.txt`
file, then run the proxy:
```bash
export RGAPI_KEY=RGAPI-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
cargo run --example proxy
cargo run --example proxy --features riven/__proxy
```
Test in your browser or using `curl`. The first path segment specifies the region:
```json
$ curl http://localhost:3000/na1/lol/summoner/v4/summoners/by-name/LugnutsK
{"id":"...","accountId":"...","puuid":"...","name":"LugnutsK","profileIconId":4540,"revisionDate":1589704662000,"summonerLevel":111}
```bash
$ curl http://localhost:3000/americas/riot/account/v1/accounts/by-riot-id/LugnutsK/000
{"puuid":"...","gameName":"LugnutsK","tagLine":"000"}
$ curl http://localhost:3000/eu/val/status/v1/platform-data
{"id": "EU", "name": "Europe", "locales": ["..."], "maintenances": [], "incidents": []}
$ curl http://localhost:3000/americas/lol/tournament-stub/v5/providers -H "Content-Type: application/json" -d '{"region":"JP","url":"https://github.com/MingweiSamuel/Riven"}'
$ curl http://localhost:3000/americas/lol/tournament-stub/v5/providers \
-H "Content-Type: application/json" -d '{"region":"JP","url":"https://github.com/MingweiSamuel/Riven"}'
1
$ curl http://localhost:3000/na1/unknown/endpoint

View file

@ -232,8 +232,7 @@ impl PlatformRoute {
}
/// Used in the LoL Tournament API. Specifically
/// [`tournament-stub-v4.registerProviderData`](crate::endpoints::TournamentStubV4::register_provider_data)
/// and [`tournament-v4.registerProviderData`](crate::endpoints::TournamentV4::register_provider_data).
/// [`TournamentStubV5`](crate::endpoints::TournamentStubV5)/[`TournamentV5`](crate::endpoints::TournamentV5).
pub fn to_tournament_region(self) -> Option<TournamentRegion> {
match self {
Self::BR1 => Some(TournamentRegion::BR),
@ -327,8 +326,7 @@ pub enum ValPlatformRoute {
}
/// Tournament regions for League of Legends (LoL) used in
/// [`tournament-stub-v4.registerProviderData`](crate::endpoints::TournamentStubV4::register_provider_data)
/// and [`tournament-v4.registerProviderData`](crate::endpoints::TournamentV4::register_provider_data).
/// [`TournamentStubV5`](crate::endpoints::TournamentStubV5)/[`TournamentV5`](crate::endpoints::TournamentV5).
#[derive(Debug)]
#[derive(PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(IntoPrimitive, TryFromPrimitive)]

View file

@ -8,7 +8,7 @@
///////////////////////////////////////////////
// http://www.mingweisamuel.com/riotapi-schema/tool/
// Version 70189fcbec142793477bfadf264265de0134d742
// Version 996d171a2b79e9bb85c549f47b07c6ef2721fc8a
//! Automatically generated endpoint handles.
#![allow(clippy::let_and_return, clippy::too_many_arguments)]
@ -300,7 +300,7 @@ impl RiotApi {
}
}
/// AccountV1 endpoints handle, accessed by calling [`account_v1()`](crate::RiotApi::account_v1) on a [`RiotApi`](crate::RiotApi) instance.
/// AccountV1 endpoints handle, accessed by calling [`account_v1()`](RiotApi::account_v1) on a [`RiotApi`] instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#account-v1" target="_blank">`account-v1`</a>
///
@ -403,7 +403,7 @@ impl<'a> AccountV1<'a> {
}
/// ChampionMasteryV4 endpoints handle, accessed by calling [`champion_mastery_v4()`](crate::RiotApi::champion_mastery_v4) on a [`RiotApi`](crate::RiotApi) instance.
/// ChampionMasteryV4 endpoints handle, accessed by calling [`champion_mastery_v4()`](RiotApi::champion_mastery_v4) on a [`RiotApi`] instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#champion-mastery-v4" target="_blank">`champion-mastery-v4`</a>
///
@ -502,7 +502,7 @@ impl<'a> ChampionMasteryV4<'a> {
}
/// ChampionV3 endpoints handle, accessed by calling [`champion_v3()`](crate::RiotApi::champion_v3) on a [`RiotApi`](crate::RiotApi) instance.
/// ChampionV3 endpoints handle, accessed by calling [`champion_v3()`](RiotApi::champion_v3) on a [`RiotApi`] instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#champion-v3" target="_blank">`champion-v3`</a>
///
@ -534,7 +534,7 @@ impl<'a> ChampionV3<'a> {
}
/// ClashV1 endpoints handle, accessed by calling [`clash_v1()`](crate::RiotApi::clash_v1) on a [`RiotApi`](crate::RiotApi) instance.
/// ClashV1 endpoints handle, accessed by calling [`clash_v1()`](RiotApi::clash_v1) on a [`RiotApi`] instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#clash-v1" target="_blank">`clash-v1`</a>
///
@ -652,7 +652,7 @@ impl<'a> ClashV1<'a> {
}
/// LeagueExpV4 endpoints handle, accessed by calling [`league_exp_v4()`](crate::RiotApi::league_exp_v4) on a [`RiotApi`](crate::RiotApi) instance.
/// LeagueExpV4 endpoints handle, accessed by calling [`league_exp_v4()`](RiotApi::league_exp_v4) on a [`RiotApi`] instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#league-exp-v4" target="_blank">`league-exp-v4`</a>
///
@ -689,7 +689,7 @@ impl<'a> LeagueExpV4<'a> {
}
/// LeagueV4 endpoints handle, accessed by calling [`league_v4()`](crate::RiotApi::league_v4) on a [`RiotApi`](crate::RiotApi) instance.
/// LeagueV4 endpoints handle, accessed by calling [`league_v4()`](RiotApi::league_v4) on a [`RiotApi`] instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#league-v4" target="_blank">`league-v4`</a>
///
@ -852,7 +852,7 @@ impl<'a> LeagueV4<'a> {
}
/// LolChallengesV1 endpoints handle, accessed by calling [`lol_challenges_v1()`](crate::RiotApi::lol_challenges_v1) on a [`RiotApi`](crate::RiotApi) instance.
/// LolChallengesV1 endpoints handle, accessed by calling [`lol_challenges_v1()`](RiotApi::lol_challenges_v1) on a [`RiotApi`] instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#lol-challenges-v1" target="_blank">`lol-challenges-v1`</a>
///
@ -991,7 +991,7 @@ impl<'a> LolChallengesV1<'a> {
}
/// LolRsoMatchV1 endpoints handle, accessed by calling [`lol_rso_match_v1()`](crate::RiotApi::lol_rso_match_v1) on a [`RiotApi`](crate::RiotApi) instance.
/// LolRsoMatchV1 endpoints handle, accessed by calling [`lol_rso_match_v1()`](RiotApi::lol_rso_match_v1) on a [`RiotApi`] instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#lol-rso-match-v1" target="_blank">`lol-rso-match-v1`</a>
///
@ -1095,7 +1095,7 @@ impl<'a> LolRsoMatchV1<'a> {
}
/// LolStatusV4 endpoints handle, accessed by calling [`lol_status_v4()`](crate::RiotApi::lol_status_v4) on a [`RiotApi`](crate::RiotApi) instance.
/// LolStatusV4 endpoints handle, accessed by calling [`lol_status_v4()`](RiotApi::lol_status_v4) on a [`RiotApi`] instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#lol-status-v4" target="_blank">`lol-status-v4`</a>
///
@ -1127,7 +1127,7 @@ impl<'a> LolStatusV4<'a> {
}
/// LorDeckV1 endpoints handle, accessed by calling [`lor_deck_v1()`](crate::RiotApi::lor_deck_v1) on a [`RiotApi`](crate::RiotApi) instance.
/// LorDeckV1 endpoints handle, accessed by calling [`lor_deck_v1()`](RiotApi::lor_deck_v1) on a [`RiotApi`] instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#lor-deck-v1" target="_blank">`lor-deck-v1`</a>
///
@ -1194,7 +1194,7 @@ impl<'a> LorDeckV1<'a> {
}
/// LorInventoryV1 endpoints handle, accessed by calling [`lor_inventory_v1()`](crate::RiotApi::lor_inventory_v1) on a [`RiotApi`](crate::RiotApi) instance.
/// LorInventoryV1 endpoints handle, accessed by calling [`lor_inventory_v1()`](RiotApi::lor_inventory_v1) on a [`RiotApi`] instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#lor-inventory-v1" target="_blank">`lor-inventory-v1`</a>
///
@ -1232,7 +1232,7 @@ impl<'a> LorInventoryV1<'a> {
}
/// LorMatchV1 endpoints handle, accessed by calling [`lor_match_v1()`](crate::RiotApi::lor_match_v1) on a [`RiotApi`](crate::RiotApi) instance.
/// LorMatchV1 endpoints handle, accessed by calling [`lor_match_v1()`](RiotApi::lor_match_v1) on a [`RiotApi`] instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#lor-match-v1" target="_blank">`lor-match-v1`</a>
///
@ -1286,7 +1286,7 @@ impl<'a> LorMatchV1<'a> {
}
/// LorRankedV1 endpoints handle, accessed by calling [`lor_ranked_v1()`](crate::RiotApi::lor_ranked_v1) on a [`RiotApi`](crate::RiotApi) instance.
/// LorRankedV1 endpoints handle, accessed by calling [`lor_ranked_v1()`](RiotApi::lor_ranked_v1) on a [`RiotApi`] instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#lor-ranked-v1" target="_blank">`lor-ranked-v1`</a>
///
@ -1318,7 +1318,7 @@ impl<'a> LorRankedV1<'a> {
}
/// LorStatusV1 endpoints handle, accessed by calling [`lor_status_v1()`](crate::RiotApi::lor_status_v1) on a [`RiotApi`](crate::RiotApi) instance.
/// LorStatusV1 endpoints handle, accessed by calling [`lor_status_v1()`](RiotApi::lor_status_v1) on a [`RiotApi`] instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#lor-status-v1" target="_blank">`lor-status-v1`</a>
///
@ -1350,7 +1350,7 @@ impl<'a> LorStatusV1<'a> {
}
/// MatchV5 endpoints handle, accessed by calling [`match_v5()`](crate::RiotApi::match_v5) on a [`RiotApi`](crate::RiotApi) instance.
/// MatchV5 endpoints handle, accessed by calling [`match_v5()`](RiotApi::match_v5) on a [`RiotApi`] instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#match-v5" target="_blank">`match-v5`</a>
///
@ -1437,7 +1437,7 @@ impl<'a> MatchV5<'a> {
}
/// SpectatorTftV5 endpoints handle, accessed by calling [`spectator_tft_v5()`](crate::RiotApi::spectator_tft_v5) on a [`RiotApi`](crate::RiotApi) instance.
/// SpectatorTftV5 endpoints handle, accessed by calling [`spectator_tft_v5()`](RiotApi::spectator_tft_v5) on a [`RiotApi`] instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#spectator-tft-v5" target="_blank">`spectator-tft-v5`</a>
///
@ -1490,7 +1490,7 @@ impl<'a> SpectatorTftV5<'a> {
}
/// SpectatorV5 endpoints handle, accessed by calling [`spectator_v5()`](crate::RiotApi::spectator_v5) on a [`RiotApi`](crate::RiotApi) instance.
/// SpectatorV5 endpoints handle, accessed by calling [`spectator_v5()`](RiotApi::spectator_v5) on a [`RiotApi`] instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#spectator-v5" target="_blank">`spectator-v5`</a>
///
@ -1543,7 +1543,7 @@ impl<'a> SpectatorV5<'a> {
}
/// SummonerV4 endpoints handle, accessed by calling [`summoner_v4()`](crate::RiotApi::summoner_v4) on a [`RiotApi`](crate::RiotApi) instance.
/// SummonerV4 endpoints handle, accessed by calling [`summoner_v4()`](RiotApi::summoner_v4) on a [`RiotApi`] instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#summoner-v4" target="_blank">`summoner-v4`</a>
///
@ -1665,7 +1665,7 @@ impl<'a> SummonerV4<'a> {
}
/// TftLeagueV1 endpoints handle, accessed by calling [`tft_league_v1()`](crate::RiotApi::tft_league_v1) on a [`RiotApi`](crate::RiotApi) instance.
/// TftLeagueV1 endpoints handle, accessed by calling [`tft_league_v1()`](RiotApi::tft_league_v1) on a [`RiotApi`] instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#tft-league-v1" target="_blank">`tft-league-v1`</a>
///
@ -1832,7 +1832,7 @@ impl<'a> TftLeagueV1<'a> {
}
/// TftMatchV1 endpoints handle, accessed by calling [`tft_match_v1()`](crate::RiotApi::tft_match_v1) on a [`RiotApi`](crate::RiotApi) instance.
/// TftMatchV1 endpoints handle, accessed by calling [`tft_match_v1()`](RiotApi::tft_match_v1) on a [`RiotApi`] instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#tft-match-v1" target="_blank">`tft-match-v1`</a>
///
@ -1894,7 +1894,7 @@ impl<'a> TftMatchV1<'a> {
}
/// TftStatusV1 endpoints handle, accessed by calling [`tft_status_v1()`](crate::RiotApi::tft_status_v1) on a [`RiotApi`](crate::RiotApi) instance.
/// TftStatusV1 endpoints handle, accessed by calling [`tft_status_v1()`](RiotApi::tft_status_v1) on a [`RiotApi`] instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#tft-status-v1" target="_blank">`tft-status-v1`</a>
///
@ -1926,7 +1926,7 @@ impl<'a> TftStatusV1<'a> {
}
/// TftSummonerV1 endpoints handle, accessed by calling [`tft_summoner_v1()`](crate::RiotApi::tft_summoner_v1) on a [`RiotApi`](crate::RiotApi) instance.
/// TftSummonerV1 endpoints handle, accessed by calling [`tft_summoner_v1()`](RiotApi::tft_summoner_v1) on a [`RiotApi`] instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#tft-summoner-v1" target="_blank">`tft-summoner-v1`</a>
///
@ -2027,7 +2027,7 @@ impl<'a> TftSummonerV1<'a> {
}
/// TournamentStubV5 endpoints handle, accessed by calling [`tournament_stub_v5()`](crate::RiotApi::tournament_stub_v5) on a [`RiotApi`](crate::RiotApi) instance.
/// TournamentStubV5 endpoints handle, accessed by calling [`tournament_stub_v5()`](RiotApi::tournament_stub_v5) on a [`RiotApi`] instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#tournament-stub-v5" target="_blank">`tournament-stub-v5`</a>
///
@ -2156,7 +2156,7 @@ impl<'a> TournamentStubV5<'a> {
}
/// TournamentV5 endpoints handle, accessed by calling [`tournament_v5()`](crate::RiotApi::tournament_v5) on a [`RiotApi`](crate::RiotApi) instance.
/// TournamentV5 endpoints handle, accessed by calling [`tournament_v5()`](RiotApi::tournament_v5) on a [`RiotApi`] instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#tournament-v5" target="_blank">`tournament-v5`</a>
///
@ -2336,7 +2336,7 @@ impl<'a> TournamentV5<'a> {
}
/// ValConsoleMatchV1 endpoints handle, accessed by calling [`val_console_match_v1()`](crate::RiotApi::val_console_match_v1) on a [`RiotApi`](crate::RiotApi) instance.
/// ValConsoleMatchV1 endpoints handle, accessed by calling [`val_console_match_v1()`](RiotApi::val_console_match_v1) on a [`RiotApi`] instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#val-console-match-v1" target="_blank">`val-console-match-v1`</a>
///
@ -2415,7 +2415,7 @@ impl<'a> ValConsoleMatchV1<'a> {
}
/// ValConsoleRankedV1 endpoints handle, accessed by calling [`val_console_ranked_v1()`](crate::RiotApi::val_console_ranked_v1) on a [`RiotApi`](crate::RiotApi) instance.
/// ValConsoleRankedV1 endpoints handle, accessed by calling [`val_console_ranked_v1()`](RiotApi::val_console_ranked_v1) on a [`RiotApi`] instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#val-console-ranked-v1" target="_blank">`val-console-ranked-v1`</a>
///
@ -2454,7 +2454,7 @@ impl<'a> ValConsoleRankedV1<'a> {
}
/// ValContentV1 endpoints handle, accessed by calling [`val_content_v1()`](crate::RiotApi::val_content_v1) on a [`RiotApi`](crate::RiotApi) instance.
/// ValContentV1 endpoints handle, accessed by calling [`val_content_v1()`](RiotApi::val_content_v1) on a [`RiotApi`] instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#val-content-v1" target="_blank">`val-content-v1`</a>
///
@ -2488,7 +2488,7 @@ impl<'a> ValContentV1<'a> {
}
/// ValMatchV1 endpoints handle, accessed by calling [`val_match_v1()`](crate::RiotApi::val_match_v1) on a [`RiotApi`](crate::RiotApi) instance.
/// ValMatchV1 endpoints handle, accessed by calling [`val_match_v1()`](RiotApi::val_match_v1) on a [`RiotApi`] instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#val-match-v1" target="_blank">`val-match-v1`</a>
///
@ -2565,7 +2565,7 @@ impl<'a> ValMatchV1<'a> {
}
/// ValRankedV1 endpoints handle, accessed by calling [`val_ranked_v1()`](crate::RiotApi::val_ranked_v1) on a [`RiotApi`](crate::RiotApi) instance.
/// ValRankedV1 endpoints handle, accessed by calling [`val_ranked_v1()`](RiotApi::val_ranked_v1) on a [`RiotApi`] instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#val-ranked-v1" target="_blank">`val-ranked-v1`</a>
///
@ -2602,7 +2602,7 @@ impl<'a> ValRankedV1<'a> {
}
/// ValStatusV1 endpoints handle, accessed by calling [`val_status_v1()`](crate::RiotApi::val_status_v1) on a [`RiotApi`](crate::RiotApi) instance.
/// ValStatusV1 endpoints handle, accessed by calling [`val_status_v1()`](RiotApi::val_status_v1) on a [`RiotApi`] instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#val-status-v1" target="_blank">`val-status-v1`</a>
///

View file

@ -1,256 +1,86 @@
#![cfg_attr(any(), rustfmt::skip)]
///////////////////////////////////////////////
// //
// ! //
// This file is automatically generated! //
// Do not directly edit! //
// //
///////////////////////////////////////////////
#![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/", env!("CARGO_PKG_README")))]
#![forbid(unsafe_code)]
#![deny(missing_docs)]
//! <h1 align="center">
//! Riven<br>
//! </h1>
//! <p align="center">
//! <a href="https://github.com/MingweiSamuel/Riven/"><img src="https://cdn.communitydragon.org/latest/champion/Riven/square" width="20" height="20" alt="Riven Github"></a>
//! <a href="https://crates.io/crates/riven"><img src="https://img.shields.io/crates/v/riven?style=flat-square&logo=rust" alt="Crates.io"></a>
//! <a href="https://docs.rs/riven/"><img src="https://img.shields.io/badge/docs.rs-Riven-blue?style=flat-square&logo=read-the-docs&logoColor=white" alt="Docs.rs"></a>
//! <!--<a href="https://travis-ci.com/MingweiSamuel/Riven"><img src="https://img.shields.io/travis/com/mingweisamuel/riven?style=flat-square" alt="Travis CI"></a>-->
//! <a href="https://github.com/rust-secure-code/safety-dance/"><img src="https://img.shields.io/badge/unsafe-forbidden-green.svg?style=flat-square" alt="unsafe forbidden"></a>
//! </p>
//!
//! Rust Library for the [Riot Games API](https://developer.riotgames.com/).
//!
//! Riven's goals are _speed_, _reliability_, and _maintainability_. Riven handles rate limits and large requests with ease.
//! Data structs and endpoints are automatically generated from the
//! [Riot API Reference](https://developer.riotgames.com/api-methods/) ([Swagger](http://www.mingweisamuel.com/riotapi-schema/tool/)).
//!
//! # Design
//!
//! * Fast, asynchronous, thread-safe.
//! * Automatically retries failed requests, configurable.
//! * Supports all endpoints, kept up-to-date using [riotapi-schema](https://github.com/MingweiSamuel/riotapi-schema).
//! * Can compile to Wasm for server-side or browser+proxy use.
//!
//! # Usage
//!
//! ```rust
//! use riven::RiotApi;
//! use riven::consts::PlatformRoute;
//!
//! // Enter tokio async runtime.
//! let rt = tokio::runtime::Runtime::new().unwrap();
//! rt.block_on(async {
//! // Create RiotApi instance from key string.
//! let api_key = std::env!("RGAPI_KEY"); // "RGAPI-01234567-89ab-cdef-0123-456789abcdef";
//! let riot_api = RiotApi::new(api_key);
//!
//! // The region.
//! let platform = PlatformRoute::NA1;
//!
//! // Get account data.
//! let account = riot_api.account_v1()
//! .get_by_riot_id(platform.to_regional(), "잘 못", "NA1").await
//! .expect("Get summoner failed.")
//! .expect("There is no summoner with that name.");
//!
//! // Print account name#tag.
//! println!(
//! "{}#{} Champion Masteries:",
//! account.game_name.unwrap_or_default(),
//! account.tag_line.unwrap_or_default(),
//! );
//!
//! // Get champion mastery data.
//! let masteries = riot_api.champion_mastery_v4()
//! .get_all_champion_masteries_by_puuid(platform, &account.puuid).await
//! .expect("Get champion masteries failed.");
//!
//! // Print champion masteries.
//! for (i, mastery) in masteries.iter().take(10).enumerate() {
//! println!("{: >2}) {: <9} {: >7} ({})", i + 1,
//! mastery.champion_id.name().unwrap_or("UNKNOWN"),
//! mastery.champion_points, mastery.champion_level);
//! }
//! });
//! ```
//! Output:
//! ```text
//! 잘 못 Champion Masteries:
//! 1) Riven 1236866 (7)
//! 2) Fiora 230679 (5)
//! 3) Katarina 175985 (5)
//! 4) Lee Sin 156070 (7)
//! 5) Jax 102662 (5)
//! 6) Gnar 76373 (6)
//! 7) Kai'Sa 64271 (5)
//! 8) Caitlyn 46614 (5)
//! 9) Irelia 46465 (5)
//! 10) Vladimir 37176 (5)
//! ```
//! The [`RiotApi` struct documentation](https://docs.rs/riven/latest/riven/struct.RiotApi.html)
//! contains additional usage information. The [tests](https://github.com/MingweiSamuel/Riven/tree/v/2.x.x/riven/tests)
//! and [example proxy](https://github.com/MingweiSamuel/Riven/tree/v/2.x.x/riven/examples/proxy)
//! provide more example usage.
//!
//! ## Feature Flags
//!
//! ### Nightly vs Stable
//!
//! Enable the `nightly` feature to use nightly-only functionality. This enables
//! [nightly optimizations in the `parking_lot` crate](https://github.com/Amanieu/parking_lot#nightly-vs-stable).
//!
//! ```toml
//! riven = { version = "...", features = [ "nightly" ] }
//! ```
//!
//! ### rustls
//!
//! Riven uses [reqwest](https://github.com/seanmonstar/reqwest) for making requests. By default, reqwest uses the native TLS library.
//! If you prefer using [rustls](https://github.com/ctz/rustls) you can do so by turning off the Riven default features
//! and specifying the `rustls-tls` feature:
//!
//! ```toml
//! riven = { version = "...", default-features = false, features = [ "rustls-tls" ] }
//! ```
//!
//! ### `log` or `tracing`
//!
//! Riven is additionally able to produce [tracing](https://docs.rs/tracing) spans for requests if the `tracing` feature is enabled.
//! By default the `tracing` feature is disabled and Riven instead writes to [`log`](https://docs.rs/log).
//!
//! ## Docs
//!
//! [On docs.rs](https://docs.rs/riven/).
//!
//! ## Error Handling
//!
//! Riven returns either `Result<T>` or `Result<Option<T>>` within futures.
//!
//! If the `Result` is errored, this indicates that the API request failed to
//! complete successfully, which may be due to bad user input, Riot server errors,
//! incorrect API key, etc.
//!
//! If the `Option` is `None`, this indicates that the request completed
//! successfully but no data was returned. This happens in several situations, such
//! as getting an account (by `name#tag`) or match (by id) that doesn't exist, or getting
//! spectator data for a summoner who is not in-game.
//! Specifically, the API returned an HTTP 404 (or 204) status code.
//!
//! The error type returned by Riven is [`RiotApiError`](https://docs.rs/riven/latest/riven/struct.RiotApiError.html).
//! It provides some basic diagnostic information, such as the source reqwest
//! error, the number of retries attempted, and the reqwest `Response` object.
//!
//! By default, Riven retries up to 3 times (4 requests total). Some errors, such
//! as 400 client errors, are not retried as they would inevitably fail again.
//!
//! You can configure Riven by creating a [`RiotApiConfig`](https://docs.rs/riven/latest/riven/struct.RiotApiConfig.html)
//! instance, setting the desired config values, and passing that to [`RiotApi::new`](https://docs.rs/riven/latest/riven/struct.RiotApi.html#method.new)
//! (instead of just the API key). For example, you can configure the number of
//! times Riven retries using [`RiotApiConfig::set_retries(...)`](https://docs.rs/riven/latest/riven/struct.RiotApiConfig.html#method.set_retries).
//!
//!
//! ## Semantic Versioning
//!
//! This package follows semantic versioning to an extent. However, the Riot API
//! itself changes often and does not follow semantic versioning, which makes
//! things difficult. Keep Riven up-to-date as out-of-date versions will slowly
//! cease to work.
//!
//! When the API changes, this may result in breaking changes in the [`models`](https://docs.rs/riven/latest/riven/models/index.html)
//! module, [`endpoints`](https://docs.rs/riven/latest/riven/endpoints/index.html)
//! module, and some of the [`consts`](https://docs.rs/riven/latest/riven/consts/index.html)
//! module. Models may receive new fields (and, less frequently, have fields
//! removed), endpoints may be added or removed, and new enum variants may be added.
//! These breaking changes will increment the **MINOR** version, not the major
//! version. (`major.minor.patch`)
//!
//! Parts of Riven that do not depend on Riot API changes do follow semantic
//! versioning.
//!
//! ## Additional Help
//!
//! Feel free to [make an issue](https://github.com/MingweiSamuel/Riven/issues/new)
//! if you are have any questions or trouble with Riven.
//!
//! # Development
//!
//! NodeJS is used to generate code for Riven. The
//! [`riven/srcgen`](https://github.com/MingweiSamuel/Riven/tree/v/2.x.x/riven/srcgen)
//! folder contains the code and [doT.js](https://olado.github.io/doT/index.html)
//! templates. `index.js` lists the JSON files downloaded and used to generate the
//! code.
//!
//! To set up the srcgen, you will first need to install NodeJS. Then enter the
//! `riven/srcgen` folder and run `npm ci` (or `npm install`) to install
//! dependencies.
//!
//! To run the srcgen use `node riven/srcgen` from the repository root.
//!
// Re-exported crates.
pub use reqwest;
pub use serde;
#[cfg(feature = "eserde")]
pub use eserde;
pub use {reqwest, serde, serde_json};
mod config;
pub use config::RiotApiConfig;
pub mod consts;
#[rustfmt::skip]
pub mod endpoints;
mod error;
pub use error::*;
pub mod meta;
#[cfg(feature = "metrics")]
mod metrics;
#[rustfmt::skip]
pub mod models;
mod models_impls;
mod req;
mod response_info;
pub use response_info::*;
mod riot_api;
pub use riot_api::*;
mod util;
/// Wasm compatibility layer for [`std::time`] or [`web_time`].
/// Time items from either [`std::time`] or from [`web_time`] for wasm.
#[rustfmt::skip]
pub mod time {
#[cfg(not(target_family = "wasm"))]
pub use std::time::*;
#[cfg(target_family = "wasm")]
pub use web_time::*;
#[doc(no_inline)]
pub use _time::{
Duration,
Instant,
SystemTime,
SystemTimeError,
TryFromFloatSecsError,
};
mod _time {
#[cfg(not(target_family = "wasm"))]
pub use std::time::*;
#[cfg(target_family = "wasm")]
pub use web_time::*;
}
#[cfg(not(target_family = "wasm"))]
pub use tokio::time::sleep;
#[cfg(target_family = "wasm")]
pub use gloo_timers::future::sleep;
/// Re-exported [`tokio::time::sleep`], or [`gloo_timers::future::sleep`] for wasm.
///
pub use _sleep::sleep;
mod _sleep {
#[cfg(not(target_family = "wasm"))]
pub use tokio::time::sleep;
#[cfg(target_family = "wasm")]
pub use gloo_timers::future::sleep;
}
}
/// Deserialization utilities from either `serde_json` or `eserde`.
/// JSON deserialization from [`serde`]/[`serde_json`], or [`eserde`] if the "eserde" feature is enabled.
#[rustfmt::skip]
pub mod de {
#[cfg(not(feature = "eserde"))]
pub use serde::Deserialize;
#[cfg(not(feature = "eserde"))]
pub use serde_json::{Error, from_str, from_slice};
/// [`serde::Deserialize`], or [`eserde::EDeserialize`] if the "eserde" feature is enabled.
///
pub use _de::Deserialize;
/// [`serde_json::Error`], or [`eserde::DeserializationErrors`] if the "eserde" feature is enabled.
///
pub use _de::Error;
/// [`serde_json::from_str`], or [`eserde::json::from_str`] if the "eserde" feature is enabled.
///
pub use _de::from_str;
/// [`serde_json::from_slice`], or [`eserde::json::from_slice`] if the "eserde" feature is enabled.
///
pub use _de::from_slice;
#[cfg(feature = "eserde")]
pub use eserde::{Deserialize, EDeserialize as Deserialize, DeserializationErrors as Error};
#[cfg(feature = "eserde")]
pub use eserde::json::{from_str, from_slice};
mod _de {
#[cfg(not(feature = "eserde"))]
pub use serde::Deserialize;
#[cfg(not(feature = "eserde"))]
pub use serde_json::{Error, from_str, from_slice};
#[cfg(feature = "eserde")]
pub use eserde::{Deserialize, EDeserialize as Deserialize, DeserializationErrors as Error};
#[cfg(feature = "eserde")]
pub use eserde::json::{from_str, from_slice};
}
}

View file

@ -8,7 +8,7 @@
///////////////////////////////////////////////
// http://www.mingweisamuel.com/riotapi-schema/tool/
// Version 70189fcbec142793477bfadf264265de0134d742
// Version 996d171a2b79e9bb85c549f47b07c6ef2721fc8a
//! Metadata about the Riot API and Riven.
//!

View file

@ -8,7 +8,7 @@
///////////////////////////////////////////////
// http://www.mingweisamuel.com/riotapi-schema/tool/
// Version 70189fcbec142793477bfadf264265de0134d742
// Version 996d171a2b79e9bb85c549f47b07c6ef2721fc8a
#![allow(missing_docs)]
@ -999,7 +999,7 @@ pub mod match_v5 {
pub game_start_timestamp: i64,
#[serde(rename = "gameType")]
///
/// Will be `None` if empty string is returned: https://github.com/RiotGames/developer-relations/issues/898
/// Will be `None` if empty string is returned: <https://github.com/RiotGames/developer-relations/issues/898>
#[serde(serialize_with = "crate::consts::serialize_empty_string_none")]
#[serde(deserialize_with = "crate::consts::deserialize_empty_string_none")]
pub game_type: Option<crate::consts::GameType>,
@ -1051,7 +1051,7 @@ pub mod match_v5 {
#[serde(rename = "championId")]
///
/// Instead use [`Self::champion()`] which checks this field then parses [`Self::champion_name`].
#[deprecated(since = "2.5.0", note = "Use `Participant.champion()` instead. Riot sometimes returns corrupted data for this field: https://github.com/RiotGames/developer-relations/issues/553")]
#[deprecated(since = "2.5.0", note = "Use `Participant.champion()` instead. Riot sometimes returns corrupted data for this field: <https://github.com/RiotGames/developer-relations/issues/553>")]
#[serde(serialize_with = "crate::consts::Champion::serialize_result")]
#[serde(deserialize_with = "crate::consts::Champion::deserialize_result")]
pub champion_id: Result<crate::consts::Champion, std::num::TryFromIntError>,
@ -1379,11 +1379,11 @@ pub mod match_v5 {
#[serde(rename = "baitPings")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub bait_pings: Option<i32>,
/// https://github.com/RiotGames/developer-relations/issues/870
/// <https://github.com/RiotGames/developer-relations/issues/870>
#[serde(rename = "dangerPings")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub danger_pings: Option<i32>,
/// https://github.com/RiotGames/developer-relations/issues/814
/// <https://github.com/RiotGames/developer-relations/issues/814>
#[serde(rename = "basicPings")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub basic_pings: Option<i32>,
@ -1397,7 +1397,7 @@ pub mod match_v5 {
#[serde(rename = "riotIdName")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub riot_id_name: Option<String>,
/// https://github.com/RiotGames/developer-relations/issues/814
/// <https://github.com/RiotGames/developer-relations/issues/814>
#[serde(rename = "retreatPings")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub retreat_pings: Option<i32>,
@ -3572,7 +3572,7 @@ pub mod tournament_stub_v5 {
/// The tournament code's region.<br>
/// (Legal values: BR, EUNE, EUW, JP, LAN, LAS, NA, OCE, PBE, RU, TR, KR)
#[serde(rename = "region")]
pub region: String,
pub region: crate::consts::TournamentRegion,
/// The game map for the tournament code game
#[serde(rename = "map")]
pub map: String,
@ -3611,7 +3611,7 @@ pub mod tournament_stub_v5 {
/// The region in which the provider will be running tournaments.<br>
/// (Legal values: BR, EUNE, EUW, JP, LAN, LAS, NA, OCE, PBE, RU, TR, KR)
#[serde(rename = "region")]
pub region: String,
pub region: crate::consts::TournamentRegion,
/// The provider's callback URL to which tournament game results in this region should be posted. The URL must be well-formed, use the http or https protocol, and use the default port for the protocol (http URLs must use port 80, https URLs must use port 443).
#[serde(rename = "url")]
pub url: String,
@ -3706,7 +3706,7 @@ pub mod tournament_v5 {
/// The tournament code's region.<br>
/// (Legal values: BR, EUNE, EUW, JP, LAN, LAS, NA, OCE, PBE, RU, TR, KR, PH, SG, TH, TW, VN)
#[serde(rename = "region")]
pub region: String,
pub region: crate::consts::TournamentRegion,
/// The game map for the tournament code game
#[serde(rename = "map")]
pub map: String,
@ -3765,7 +3765,7 @@ pub mod tournament_v5 {
pub game_mode: String,
/// Region of the game
#[serde(rename = "region")]
pub region: String,
pub region: crate::consts::TournamentRegion,
}
/// `tournament-v5.TournamentTeamV5` data object.
#[derive(Clone, Debug)]
@ -3807,7 +3807,7 @@ pub mod tournament_v5 {
/// The region in which the provider will be running tournaments.<br>
/// (Legal values: BR, EUNE, EUW, JP, LAN, LAS, NA, OCE, PBE, RU, TR, KR, PH, SG, TH, TW, VN)
#[serde(rename = "region")]
pub region: String,
pub region: crate::consts::TournamentRegion,
/// The provider's callback URL to which tournament game results in this region should be posted. The URL must be well-formed, use the http or https protocol, and use the default port for the protocol (http URLs must use port 80, https URLs must use port 443).
#[serde(rename = "url")]
pub url: String,

View file

@ -99,8 +99,7 @@ impl PlatformRoute {
}
/// Used in the LoL Tournament API. Specifically
/// [`tournament-stub-v4.registerProviderData`](crate::endpoints::TournamentStubV4::register_provider_data)
/// and [`tournament-v4.registerProviderData`](crate::endpoints::TournamentV4::register_provider_data).
/// [`TournamentStubV5`](crate::endpoints::TournamentStubV5)/[`TournamentV5`](crate::endpoints::TournamentV5).
pub fn to_tournament_region(self) -> Option<TournamentRegion> {
match self {
{{
@ -166,8 +165,7 @@ pub enum ValPlatformRoute {
}
/// Tournament regions for League of Legends (LoL) used in
/// [`tournament-stub-v4.registerProviderData`](crate::endpoints::TournamentStubV4::register_provider_data)
/// and [`tournament-v4.registerProviderData`](crate::endpoints::TournamentV4::register_provider_data).
/// [`TournamentStubV5`](crate::endpoints::TournamentStubV5)/[`TournamentV5`](crate::endpoints::TournamentV5).
#[derive(Debug)]
#[derive(PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(IntoPrimitive, TryFromPrimitive)]

View file

@ -57,7 +57,7 @@ impl RiotApi {
const endpoint_snake_case = dotUtils.changeCase.snakeCase(endpointName);
}}
/// {{= endpoint }} endpoints handle, accessed by calling [`{{= endpoint_snake_case }}()`](crate::RiotApi::{{= endpoint_snake_case }}) on a [`RiotApi`](crate::RiotApi) instance.
/// {{= endpoint }} endpoints handle, accessed by calling [`{{= endpoint_snake_case }}()`](RiotApi::{{= endpoint_snake_case }}) on a [`RiotApi`] instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#{{= endpointName }}" target="_blank">`{{= endpointName }}`</a>
///

View file

@ -1,76 +0,0 @@
{{
const dotUtils = require('./dotUtils.js');
const readme = require('fs').readFileSync('../../README.md', 'utf-8').split(/\r?\n/);
}}{{= dotUtils.preamble() }}
#![forbid(unsafe_code)]
#![deny(missing_docs)]
{{~ readme :line }}
//!{{= line ? (' ' + line) : '' }}
{{~}}
// Re-exported crates.
pub use reqwest;
pub use serde;
#[cfg(feature = "eserde")]
pub use eserde;
mod config;
pub use config::RiotApiConfig;
pub mod consts;
#[rustfmt::skip]
pub mod endpoints;
mod error;
pub use error::*;
pub mod meta;
#[cfg(feature = "metrics")]
mod metrics;
#[rustfmt::skip]
pub mod models;
mod models_impls;
mod req;
mod response_info;
pub use response_info::*;
mod riot_api;
pub use riot_api::*;
mod util;
/// Wasm compatibility layer for [`std::time`] or [`web_time`].
#[rustfmt::skip]
pub mod time {
#[cfg(not(target_family = "wasm"))]
pub use std::time::*;
#[cfg(target_family = "wasm")]
pub use web_time::*;
#[cfg(not(target_family = "wasm"))]
pub use tokio::time::sleep;
#[cfg(target_family = "wasm")]
pub use gloo_timers::future::sleep;
}
/// Deserialization utilities from either `serde_json` or `eserde`.
#[rustfmt::skip]
pub mod de {
#[cfg(not(feature = "eserde"))]
pub use serde::Deserialize;
#[cfg(not(feature = "eserde"))]
pub use serde_json::{Error, from_str, from_slice};
#[cfg(feature = "eserde")]
pub use eserde::{Deserialize, EDeserialize as Deserialize, DeserializationErrors as Error};
#[cfg(feature = "eserde")]
pub use eserde::json::{from_str, from_slice};
}

View file

@ -40,7 +40,7 @@ pub mod {{= dotUtils.changeCase.snakeCase(endpoint) }} {
/// `{{= endpoint }}.{{= rawSchemaName }}` data object.
{{? schema.description }}
/// # Description
/// {{= schema.description.split('\n').map(x => x.trim()).join('<br>\r\n /// ') }}
/// {{= schema.description.replace(/https?:\/\/\S+[^\s\.!?]/g, "<$&>").split('\n').map(x => x.trim()).join('<br>\r\n /// ') }}
///
/// Note: This struct is automatically generated
{{?}}
@ -61,7 +61,7 @@ pub mod {{= dotUtils.changeCase.snakeCase(endpoint) }} {
usedNames.add(name);
}}
{{? prop.description }}
/// {{= prop.description.split('\n').map(x => x.trim()).join('<br>\r\n /// ') }}
/// {{= prop.description.replace(/https?:\/\/\S+[^\s\.!?]/g, "<$&>").split('\n').map(x => x.trim()).join('<br>\r\n /// ') }}
{{?}}
{{= dotUtils.formatJsonProperty(propKey, prop) }}
{{? optional }}
@ -70,13 +70,13 @@ pub mod {{= dotUtils.changeCase.snakeCase(endpoint) }} {
{{? 'championId' === propKey && (prop.description || '').includes('this field returned invalid championIds') }}
///
/// Instead use [`Self::champion()`] which checks this field then parses [`Self::champion_name`].
#[deprecated(since = "2.5.0", note = "Use `Participant.champion()` instead. Riot sometimes returns corrupted data for this field: https://github.com/RiotGames/developer-relations/issues/553")]
#[deprecated(since = "2.5.0", note = "Use `Participant.champion()` instead. Riot sometimes returns corrupted data for this field: <https://github.com/RiotGames/developer-relations/issues/553>")]
#[serde(serialize_with = "crate::consts::Champion::serialize_result")]
#[serde(deserialize_with = "crate::consts::Champion::deserialize_result")]
pub {{= name }}: Result<crate::consts::Champion, std::num::TryFromIntError>,
{{?? 'gameType' === propKey && 'Info' === schemaName && 'match-v5' === endpoint }}
///
/// Will be `None` if empty string is returned: https://github.com/RiotGames/developer-relations/issues/898
/// Will be `None` if empty string is returned: <https://github.com/RiotGames/developer-relations/issues/898>
#[serde(serialize_with = "crate::consts::serialize_empty_string_none")]
#[serde(deserialize_with = "crate::consts::deserialize_empty_string_none")]
pub {{= name }}: Option<crate::consts::GameType>,

View file

@ -55,7 +55,7 @@ async fn tournamentstub() -> Result<(), String> {
.register_provider_data(
ROUTE,
&ProviderRegistrationParametersV5 {
region: PlatformRoute::NA1.as_region_str().to_owned(),
region: PlatformRoute::NA1.to_tournament_region().unwrap(),
url: "https://github.com/MingweiSamuel/Riven".to_owned(),
},
)

View file

@ -2,12 +2,12 @@
set -euxo pipefail
# Ensure stable builds.
cargo +stable check --all-targets --features __proxy
cargo +stable check --all-targets --features metrics,tracing,__proxy
cargo +stable check --all-targets --features riven/__proxy
cargo +stable check --all-targets --features riven/metrics,riven/tracing,riven/__proxy
# Ensure nightly builds.
cargo check --all-targets --features nightly,metrics,tracing,__proxy
cargo build --all-targets --features nightly,deny-unknown,eserde,__proxy
cargo check --all-targets --features riven/nightly,riven/metrics,riven/tracing,riven/__proxy
cargo build --all-targets --features riven/nightly,riven/deny-unknown,riven/eserde,riven/__proxy
# Run nightly tests.
bash test.bash

View file

@ -1,4 +1,5 @@
#!/bin/bash
set -euxo pipefail
RGAPI_KEY="$(cat apikey.txt)" RUST_BACKTRACE=full RUST_LOG=riven=debug cargo test --no-fail-fast --features nightly,tracing,eserde,deny-unknown,eserde -- --nocapture
RGAPI_KEY="$(cat apikey.txt)" cargo test --no-fail-fast \
--features riven/nightly,riven/tracing,riven/eserde,riven/deny-unknown -- --nocapture