[][src]Struct brawl_api::model::brawlers::Brawler

pub struct Brawler {
    pub name: String,
    pub id: usize,
    pub star_powers: Vec<StarPower>,
}

Contains information for a specific brawler, and allows for it to be fetched through Brawler::fetch.

Fields

name: String

The brawler's name, in CAPS LOCK. E.g.: "SHELLY" for Shelly.

id: usize

The brawler's ID (an arbitrary number representing it).

star_powers: Vec<StarPower>

The brawler's star powers, as a vector (note that this does not have a fixed size: new brawlers start with 1 star power, while older ones have at least 2.)

Methods

impl Brawler[src]

pub fn get_fetch_prop(&self) -> usize[src]

Returns this Brawler's ID, which is used for fetching.

Examples

use brawl_api::{Brawler, traits::*};

// given an existing Brawler object
let brawler: Brawler;

assert_eq!(brawler.get_fetch_prop(), brawler.id);

pub fn get_route(id: usize) -> Route[src]

Returns the Route object required for fetching a Brawler instance.

Examples

use brawl_api::{BrawlerList, http::Route};

assert_eq!(
    BrawlerList::get_route(),
    Route::Brawlers
);

pub fn fetch(client: &Client, id: usize) -> Result<Brawler>[src]

(Sync) Fetches data for a brawler with a specific ID (see the Brawlers enum for a humanized list with IDs).

Errors

This function may error:

  • While requesting (will return an Error::Request);
  • After receiving a bad status code (API or other error - returns an Error::Status);
  • After a ratelimit is indicated by the API, while also specifying when it is lifted (Error::Ratelimited);
  • While parsing incoming JSON (will return an Error::Json).

(All of those, of course, wrapped inside an Err.)

Examples

This example is not tested
use brawl_api::{Client, Brawler, Brawlers, traits::*};

let my_client = Client::new("my auth token");
let shelly = Brawler::fetch(&my_client, Brawlers::Shelly as usize)?;
// now the data for Shelly is available.

pub async fn a_fetch<'_>(client: &'_ Client, id: usize) -> Result<Brawler>[src]

(Async) Fetches data for a brawler with a specific ID (see the Brawlers enum for a humanized list with IDs).

Errors

This function may error:

  • While requesting (will return an Error::Request);
  • After receiving a bad status code (API or other error - returns an Error::Status);
  • After a ratelimit is indicated by the API, while also specifying when it is lifted (Error::Ratelimited);
  • While parsing incoming JSON (will return an Error::Json).

(All of those, of course, wrapped inside an Err.)

Examples

This example is not tested
use brawl_api::{Client, Brawler, Brawlers, traits::*};

let my_client = Client::new("my auth token");
let shelly = Brawler::a_fetch(&my_client, Brawlers::Shelly as usize).await?;
// now the data for Shelly is available.

Trait Implementations

impl Clone for Brawler[src]

impl Debug for Brawler[src]

impl Default for Brawler[src]

fn default() -> Brawler[src]

Returns an instance of Brawler with initial values.

Examples

use brawl_api::Brawler;

assert_eq!(
    Brawler::default(),
    Brawler {
        name: String::from(""),
        id: 0,
        star_powers: vec![]
    }
);

impl<'de> Deserialize<'de> for Brawler[src]

impl Eq for Brawler[src]

impl FetchFrom<BattleBrawler> for Brawler[src]

fn fetch_from(client: &Client, b_brawler: &BattleBrawler) -> Result<Brawler>[src]

(Sync) Attempts to fetch a Brawler from an existing BattleBrawler instance.

fn a_fetch_from<'life0, 'life1, 'async_trait>(
    client: &'life0 Client,
    b_brawler: &'life1 BattleBrawler
) -> Pin<Box<dyn Future<Output = Result<Brawler>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait, 
[src]

(Async) Attempts to fetch a Brawler from an existing BattleBrawler instance.

impl FetchFrom<Brawlers> for Brawler[src]

fn fetch_from(client: &Client, b_brawler: &Brawlers) -> Result<Brawler>[src]

(Sync) Attempts to fetch a Brawler from an existing Brawlers variant.

fn a_fetch_from<'life0, 'life1, 'async_trait>(
    client: &'life0 Client,
    b_brawler: &'life1 Brawlers
) -> Pin<Box<dyn Future<Output = Result<Brawler>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait, 
[src]

(Async) Attempts to fetch a Brawler from an existing Brawlers variant.

impl FetchFrom<PlayerBrawlerStat> for Brawler[src]

fn fetch_from(client: &Client, p_brawler: &PlayerBrawlerStat) -> Result<Brawler>[src]

(Sync) Attempts to fetch a Brawler from an existing PlayerBrawlerStat instance.

fn a_fetch_from<'life0, 'life1, 'async_trait>(
    client: &'life0 Client,
    p_brawler: &'life1 PlayerBrawlerStat
) -> Pin<Box<dyn Future<Output = Result<Brawler>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait, 
[src]

(Async) Attempts to fetch a Brawler from an existing PlayerBrawlerStat instance.

impl Hash for Brawler[src]

impl PartialEq<Brawler> for Brawler[src]

impl Refetchable for Brawler[src]

fn refetch(&self, client: &Client) -> Result<Brawler>[src]

(Sync) Fetches data for this brawler again.

fn a_refetch<'life0, 'life1, 'async_trait>(
    &'life0 self,
    client: &'life1 Client
) -> Pin<Box<dyn Future<Output = Result<Brawler>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

(Async) Fetches data for this brawler again.

impl Serialize for Brawler[src]

impl StructuralEq for Brawler[src]

impl StructuralPartialEq for Brawler[src]

Auto Trait Implementations

impl RefUnwindSafe for Brawler

impl Send for Brawler

impl Sync for Brawler

impl Unpin for Brawler

impl UnwindSafe for Brawler

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> FetchFrom<T> for T where
    T: Clone + Send + Sync
[src]

fn fetch_from(&Client, &T) -> Result<T, Error>[src]

(Sync) Returns a copy of the current instance when attempting to fetch from itself. In order to re-fetch, see Refetchable.

Errors

Never errors; is only a Result in order to match the trait signature.

fn a_fetch_from<'life0, 'life1, 'async_trait>(
    &'life0 Client,
    &'life1 T
) -> Pin<Box<dyn Future<Output = Result<T, Error>> + 'async_trait + Send>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    T: 'async_trait, 
[src]

(Async) Returns a copy of the current instance when attempting to fetch from itself. In order to re-fetch, see Refetchable.

Errors

Never errors; is only a Result in order to match the trait signature.

impl<T, U> FetchInto<U> for T where
    T: Sync + Send,
    U: FetchFrom<T> + Sync + Send
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Refetchable for T where
    T: PropFetchable<Property = <T as GetFetchProp>::Property> + GetFetchProp + Send + Sync,
    <T as GetFetchProp>::Property: Sync,
    <T as GetFetchProp>::Property: Send
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,