[][src]Struct brawl_api::model::players::player::Player

pub struct Player {
    pub club: Option<PlayerClub>,
    pub is_qualified_from_championship_challenge: bool,
    pub tvt_victories: usize,
    pub tag: String,
    pub name: String,
    pub trophies: usize,
    pub highest_trophies: usize,
    pub exp_level: usize,
    pub exp_points: usize,
    pub power_play_points: usize,
    pub highest_power_play_points: usize,
    pub solo_victories: usize,
    pub duo_victories: usize,
    pub best_robo_rumble_time: usize,
    pub best_time_as_big_brawler: usize,
    pub brawlers: Vec<PlayerBrawlerStat>,
    pub name_color: u64,
}

A struct representing a Brawl Stars player, with all of its data. Use Player::fetch to fetch one based on tag. (Make sure the PropFetchable trait is imported - in general, it is recommended to at least use brawl_api::traits::*, or, even, use brawl_api::prelude::* to bring the models into scope as well.)

Fields

club: Option<PlayerClub>

The club the Player is in (as a PlayerClub instance), or None if none.

is_qualified_from_championship_challenge: bool

Whether or not the Player was qualified from the Championship challenge (2020).

tvt_victories: usize

Amount of 3v3 victories the Player has earned.

tag: String

The player's tag. Note: this includes the initial '#'.

name: String

The player's name.

trophies: usize

The player's current trophies.

highest_trophies: usize

The player's highest trophies amount.

exp_level: usize

The player's experience level.

exp_points: usize

The player's experience points.

power_play_points: usize

The player's current power play points.

highest_power_play_points: usize

The player's highest power play points.

solo_victories: usize

The player's victories in solo showdown (how many times ranked #1).

duo_victories: usize

The player's victories in duo showdown (how many times ranked #1).

best_robo_rumble_time: usize

The player's best Robo Rumble time, in seconds.

best_time_as_big_brawler: usize

The player's best time as a Big Brawler, in seconds.

brawlers: Vec<PlayerBrawlerStat>

The player's brawlers.

name_color: u64

The player's name color, as an integer (Default is 0xffffff = 16777215 - this is used when the data is not available).

Trait Implementations

impl Clone for Player[src]

impl Debug for Player[src]

impl Default for Player[src]

fn default() -> Player[src]

Initializes a Player instance with default values for each field.

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

impl Eq for Player[src]

impl FetchFrom<BattlePlayer> for Player[src]

fn fetch_from(client: &Client, b_player: &BattlePlayer) -> Result<Player>[src]

(Async) Fetches a Player instance, given a preexisting BattlePlayer instance.

Errors

See Player::fetch.

Examples

This example is not tested
use brawl_api::{
    Client, Player, BattleLog, Battle, BattleResultInfo, BattlePlayer,
    traits::*
};

let my_client = Client::new("my auth token");
let battlelog = BattleLog::fetch(&my_client, "#PLAYER_TAG_HERE")?;
let most_recent_battle: Option<&Battle> = battlelog.get(0);

if let Some(battle) = most_recent_battle {
    if let Some(ref teams) = &battle.result.teams {
        let some_b_player: &BattlePlayer = &teams[0][0];
        let some_player = Player::fetch_from(&my_client, some_b_player)?;
        // now `some_b_player`'s full data, as a Player, is available for use.
    }
}

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

(Async) Fetches a Player instance, given a preexisting BattlePlayer instance.

Errors

See Player::fetch.

Examples

This example is not tested
use brawl_api::{
    Client, Player, BattleLog, Battle, BattleResultInfo, BattlePlayer,
    traits::*
};

let my_client = Client::new("my auth token");
let battlelog = BattleLog::a_fetch(&my_client, "#PLAYER_TAG_HERE").await?;
let most_recent_battle: Option<&Battle> = battlelog.get(0);

if let Some(battle) = most_recent_battle {
    if let Some(ref teams) = &battle.result.teams {
        let some_b_player: &BattlePlayer = &teams[0][0];
        let some_player = Player::a_fetch_from(&my_client, some_b_player).await?;
        // now `some_b_player`'s full data, as a Player, is available for use.
    }
}

impl FetchFrom<ClubMember> for Player[src]

fn fetch_from(client: &Client, member: &ClubMember) -> Result<Player>[src]

(Sync) Fetches a Player instance, given a preexisting ClubMember instance.

Errors

See Player::fetch.

Examples

This example is not tested
use brawl_api::{Client, Player, Club, traits::*};

let my_client = Client::new("my auth token");
let club = Club::fetch(&my_client, "#CLUB_TAG_HERE")?;
let some_member = &club.members[0];
let some_player = Player::fetch_from(&my_client, some_member)?;
// now `some_member`'s full data, as a Player, is available for use.

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

(Async) Fetches a Player instance, given a preexisting ClubMember instance.

Errors

See Player::fetch.

Examples

This example is not tested
use brawl_api::{Client, Player, Club, traits::*};

let my_client = Client::new("my auth token");
let club = Club::a_fetch(&my_client, "#CLUB_TAG_HERE").await?;
let some_member = &club.members[0];
let some_player = Player::a_fetch_from(&my_client, some_member).await?;
// now `some_member`'s full data, as a Player, is available for use.

impl FetchFrom<Player> for BattleLog[src]

fn fetch_from(client: &Client, player: &Player) -> Result<BattleLog>[src]

(Sync) Fetches a given player's battlelog (a BattleLog instance) by using data from an existing Player instance. (See BattleLog::fetch for more details.)

Note that this is simply to minimize efforts when a player was already fetched. If no Player instance was previously present, it is recommended to simply BattleLog::fetch with the specific player's tag.

Examples

This example is not tested
use brawl_api::{Client, Player, BattleLog, traits::*};

let my_client = Client::new("my auth token");
let player = Player::fetch(&my_client, "#PLAYERTAGHERE")?;
// do stuff with player...
let player_battlelog = BattleLog::fetch_from(&my_client, &player)?;
// now the player's battlelog is available for use

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

(Async) Fetches a given player's battlelog (a BattleLog instance) by using data from an existing Player instance. (See BattleLog::fetch for more details.)

Note that this is simply to minimize efforts when a player was already fetched. If no Player instance was previously present, it is recommended to simply BattleLog::fetch with the specific player's tag.

Examples

This example is not tested
use brawl_api::{Client, Player, BattleLog, traits::*};

let my_client = Client::new("my auth token");
let player = Player::a_fetch(&my_client, "#PLAYERTAGHERE").await?;
// do stuff with player...
let player_battlelog = BattleLog::a_fetch_from(&my_client, &player).await?;
// now the player's battlelog is available for use

impl FetchFrom<PlayerRanking> for Player[src]

fn fetch_from(client: &Client, p_ranking: &PlayerRanking) -> Result<Player>[src]

(Sync) Fetches a Player using data from a PlayerRanking object.

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

(Async) Fetches a Player using data from a PlayerRanking object.

impl GetFetchProp for Player[src]

type Property = str

impl Hash for Player[src]

impl PartialEq<Player> for Player[src]

impl PropFetchable for Player[src]

type Property = str

fn fetch(client: &Client, tag: &str) -> Result<Player>[src]

(Sync) Fetches a player from its tag.

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, Player, traits::*};

let my_client = Client::new("my auth token");
let player = Player::fetch(&my_client, "#PLAYERTAGHERE")?;
// now the data for the given player is available for use

fn a_fetch<'life0, 'async_trait>(
    client: &'life0 Client,
    tag: &'async_trait str
) -> Pin<Box<dyn Future<Output = Result<Player>> + Send + 'async_trait>> where
    Self: 'async_trait,
    Self::Property: 'async_trait,
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

(Async) Fetches a player from its tag.

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, Player, traits::*};

let my_client = Client::new("my auth token");
let player = Player::a_fetch(&my_client, "#PLAYERTAGHERE").await?;
// now the data for the given player is available for use

impl Serialize for Player[src]

impl StructuralEq for Player[src]

impl StructuralPartialEq for Player[src]

Auto Trait Implementations

impl RefUnwindSafe for Player

impl Send for Player

impl Sync for Player

impl Unpin for Player

impl UnwindSafe for Player

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> PropRouteable for T where
    T: GetFetchProp
[src]

type Property = <T as GetFetchProp>::Property

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>,