Function fetch_runes

Source
pub async fn fetch_runes(
    champion_id: &str,
) -> Result<RunesData, Box<dyn Error + Send + Sync>>
Expand description

⚙️ Function: Fetches rune data for a specific champion from League of Graphs.

This asynchronous function retrieves the rune build information for a given champion by making an HTTP request to League of Graphs. It then parses the HTML response to extract the rune tables and returns the runes in the RunesData structure.

§Parameters:

  • champion_id: A string slice representing the champion’s identifier, used to build the URL for fetching the rune information.

§Returns:

  • Result<RunesData, Error>: Returns a RunesData struct with the champion’s rune information if successful, or an error if something goes wrong during the HTTP request or parsing.

§Example:

This function is typically called to retrieve the rune data for a specific champion:

let runes = fetch_runes("Rammus").await?;
println!("{:?}", runes);

§Notes:

  • The function makes an HTTP request to the League of Graphs page using the champion’s ID to construct the URL.
  • It then parses the HTML to find the rune tables and extracts the relevant rune data.
  • The extract_runes function is used to process the HTML and return the rune information in the RunesData structure.
  • This function expects two rune tables (primary and secondary) to be present in the response, otherwise it will panic with an unwrap() error.