Function match_role_with_database_roles

Source
fn match_role_with_database_roles(role: Role) -> String
Expand description

⚙️ Maps a Role enum value to its corresponding string representation as stored in the database.

This function takes a Role enum and converts it to a String that matches the format used in the database. It is used to ensure consistency between the role representation in the code and the role names stored in the database.

§Parameters:

  • role: A Role enum representing the role to be converted.

§Returns:

  • String: The corresponding string representation of the role (e.g., “Top”, “Jungler”).

§Example:

let role = Role::TOPLANE;
let role_str = match_role_with_database_roles(role);
assert_eq!(role_str, "Top");

§⚠️ Notes:

  • The function uses Rust’s match control flow to convert each Role variant to the corresponding string.
  • This function is essential for ensuring compatibility between different parts of the code and the data storage layer.
  • Role: Represents different League of Legends roles like TOPLANE, JUNGLE, MIDLANE, etc.

§See Also:

  • get_champions_by_role: Uses the string representation of a role to query the database for champions with that role.