mirror of
https://github.com/MingweiSamuel/Riven.git
synced 2024-12-27 03:16:33 +00:00
readme example
This commit is contained in:
parent
1581425206
commit
3d0b42e31c
4 changed files with 15 additions and 13 deletions
12
README.md
12
README.md
|
@ -23,9 +23,13 @@ Riven currently uses nightly Rust.
|
|||
use riven::RiotApi;
|
||||
use riven::consts::Region;
|
||||
|
||||
async {
|
||||
// Enter tokio async runtime.
|
||||
let rt = tokio::runtime::Runtime::new().unwrap();
|
||||
rt.block_on(async {
|
||||
// Create RiotApi instance from key.
|
||||
let riot_api = RiotApi::with_key("RGAPI-01234567-89ab-cdef-0123-456789abcdef");
|
||||
let api_key = "RGAPI-01234567-89ab-cdef-0123-456789abcdef";
|
||||
# let api_key = std::env::var("RGAPI_KEY").ok().or_else(|| std::fs::read_to_string("apikey.txt").ok()).unwrap();
|
||||
let riot_api = RiotApi::with_key(api_key);
|
||||
|
||||
// Get summoner data.
|
||||
let summoner = riot_api.summoner_v4()
|
||||
|
@ -48,10 +52,8 @@ async {
|
|||
mastery.champion_id.to_string(),
|
||||
mastery.champion_points, mastery.champion_level);
|
||||
}
|
||||
}
|
||||
});
|
||||
```
|
||||
Full code in [tests/readme.rs.ignored](./tests/readme.rs.ignored)
|
||||
|
||||
Output:
|
||||
```text
|
||||
잘 못 Champion Masteries:
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
///////////////////////////////////////////////
|
||||
// //
|
||||
// ! //
|
||||
// This file is automatically generated! //
|
||||
// Do not directly edit! //
|
||||
// //
|
||||
///////////////////////////////////////////////
|
||||
// //
|
||||
// ! //
|
||||
// This file is automatically generated! //
|
||||
// Do not directly edit! //
|
||||
// //
|
||||
///////////////////////////////////////////////
|
||||
|
||||
use serde_repr::{ Serialize_repr, Deserialize_repr };
|
||||
|
|
|
@ -7,7 +7,7 @@ macro_rules! async_tests {
|
|||
env_logger::init();
|
||||
|
||||
std::process::exit({
|
||||
let mut rt = tokio::runtime::current_thread::Runtime::new()
|
||||
let rt = tokio::runtime::Runtime::new()
|
||||
.expect("Failed to create runtime.");
|
||||
|
||||
let (_, errs) = rt.block_on(async {
|
||||
|
|
|
@ -19,7 +19,7 @@ async_tests!{
|
|||
my_runner {
|
||||
league_summoner_bulk_test: async {
|
||||
|
||||
let leagues = (1..20)
|
||||
let leagues = (1..10)
|
||||
.map(async move |i| {
|
||||
let leaguelist = RIOT_API.league_v4().get_league_entries(REGION,
|
||||
QueueType::RANKED_SOLO_5x5, Tier::GOLD, Division::III, Some(i));
|
||||
|
|
Loading…
Reference in a new issue