UtilsApi

Struct UtilsApi 

Source
pub struct UtilsApi {
    pub version: String,
    pub language: String,
}

Fields§

§version: String§language: String

Implementations§

Source§

impl UtilsApi

Source

pub fn latest(language: &str) -> Option<UtilsApi>

Creates a new UtilsApi using the latest available version and custom language.

§Examples

Basic usage: (current latest version is 12.12.1 (07/05/2022))

use samira::utils_api::*;

let api = UtilsApi::latest("en_US").unwrap_or_default();
assert_eq!(api, UtilsApi{version: "12.12.1".to_owned(), language: "en_US".to_owned()});
Source

pub fn new(version: &str, language: &str) -> Option<UtilsApi>

Creates a new UtilsApi using a custom version and custom language.

§Examples

Basic usage:

use samira::utils_api::*;

let api = UtilsApi::new("12.12.1", "fr_FR").unwrap_or_default();
assert_eq!(api, UtilsApi{version: "12.12.1".to_owned(), language: "fr_FR".to_owned()});
Source

pub fn get_all_champions(&self) -> Vec<Champion>

Retrieve all current champions.

§Examples

Basic usage:

use samira::{models::champion_model::*, utils_api::*};

let api = UtilsApi::new("12.12.1", "fr_FR").unwrap_or_default();
let champions = api.get_all_champions();
assert_eq!(champions.iter().find(|&c| c.name == "Samira").is_some(), true);
assert_eq!(champions.iter().find(|&c| c.name == "Akali").is_some(), true);
assert_eq!(champions.iter().find(|&c| c.name == "RqndomChampion").is_some(), false);
Source

pub fn get_champion_by_key(&self, key: String) -> Option<Champion>

Retrieve a champion from its id.

§Examples

Basic usage:

use samira::{models::champion_model::*, utils_api::*};

let api = UtilsApi::latest("en_US").unwrap_or_default();
assert_eq!("360", api.get_champion_by_key("360".to_owned()).unwrap().key);
Source

pub fn get_champion_by_name(&self, name: String) -> Option<Champion>

Retrieve a champion from its name.

§Examples

Basic usage:

use samira::{models::champion_model::*, utils_api::*};

let api = UtilsApi::latest("en_US").unwrap_or_default();
assert_eq!("Samira", api.get_champion_by_name("Samira".to_owned()).unwrap().name);
Source

pub fn get_rune(&self, name: String) -> Option<Rune>

Retrieve a rune by its name

§Examples

Basic usage:

use samira::{models::rune_model::*, utils_api::*};

let api = UtilsApi::latest("en_US").unwrap_or_default();
assert_eq!("Domination", api.get_rune("Domination".to_owned()).unwrap().name);
assert_eq!("Inspiration", api.get_rune("Inspiration".to_owned()).unwrap().name);
Source

pub fn get_all_runes(&self) -> Vec<Rune>

Retrieve all current runes

§Examples

Basic usage:

use samira::{models::rune_model::*, utils_api::*};

let api = UtilsApi::new("12.12.1", "fr_FR").unwrap_or_default();
let runes = api.get_all_runes();
assert_eq!(runes.iter().find(|&c| c.name == "Domination").is_some(), true);
assert_eq!(runes.iter().find(|&c| c.name == "Inspiration").is_some(), true);
assert_eq!(runes.iter().find(|&c| c.id == 8400).is_some(), true);
assert_eq!(runes.iter().find(|&c| c.name == "RqndomRune").is_some(), false);

Trait Implementations§

Source§

impl Debug for UtilsApi

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for UtilsApi

Source§

fn default() -> UtilsApi

Returns the “default value” for a type. Read more
Source§

impl PartialEq for UtilsApi

Source§

fn eq(&self, other: &UtilsApi) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for UtilsApi

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,