From ee1778284d15633230d1898fb0ef9706ae65e91e Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 21 Mar 2023 15:39:00 +0100 Subject: [PATCH] Add `create_globalindexes_from_dd_latest_en_us` --- src/data/corebundle/mod.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/data/corebundle/mod.rs b/src/data/corebundle/mod.rs index 4dbdedc..a95aa05 100644 --- a/src/data/corebundle/mod.rs +++ b/src/data/corebundle/mod.rs @@ -77,6 +77,19 @@ pub fn create_globalindexes_from_wd() -> globals::LocalizedGlobalsIndexes { } +/// Create [`globals::LocalizedGlobalsIndexes`] from the latest english data in Data Dragon. +/// +/// This function tries to load data from `https://dd.b.pvp.net/latest`. +pub async fn create_globalindexes_from_dd_latest_en_us() -> globals::LocalizedGlobalsIndexes { + let client = reqwest::Client::new(); + + let core = CoreBundle::fetch(&client, "https://dd.b.pvp.net/latest", "en_us").await + .expect("to be able to fetch `core-en_us` bundle"); + + globals::LocalizedGlobalsIndexes::from(core.globals) +} + + #[cfg(test)] mod tests { macro_rules! test_fetch {