Skip to main content

Player

Struct Player 

Source
pub struct Player {
Show 17 fields 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,
}
Expand description

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§

Source§

impl Clone for Player

Source§

fn clone(&self) -> Player

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Player

Source§

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

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

impl Default for Player

Source§

fn default() -> Player

Initializes a Player instance with default values for each field.

Source§

impl<'de> Deserialize<'de> for Player

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Player

Source§

impl FetchFrom<BattlePlayer> for Player

Source§

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

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

§Errors

See Player::fetch.

§Examples
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.
    }
}
Source§

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,

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

§Errors

See Player::fetch.

§Examples
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.
    }
}
Source§

impl FetchFrom<ClubMember> for Player

Source§

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

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

§Errors

See Player::fetch.

§Examples
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.
Source§

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,

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

§Errors

See Player::fetch.

§Examples
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.
Source§

impl FetchFrom<Player> for BattleLog

Source§

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

(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
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
Source§

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,

(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
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
Source§

impl FetchFrom<PlayerRanking> for Player

Source§

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

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

Source§

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,

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

Source§

impl GetFetchProp for Player

Source§

type Property = str

Source§

fn get_fetch_prop(&self) -> &str

Obtain the revelant property for fetching.
Source§

fn get_route(tag: &str) -> Route

Obtain the route for fetching by using a property.
Source§

impl Hash for Player

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Player

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 PropFetchable for Player

Source§

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

(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
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
Source§

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,

(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
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
Source§

type Property = str

Source§

impl Serialize for Player

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Player

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

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

Source§

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

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> FetchFrom<T> for T
where T: Sync + Send + Clone,

Source§

fn fetch_from(_: &Client, t: &T) -> Result<T, Error>

(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.

Source§

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

(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.

Source§

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

Source§

fn fetch_into(&self, client: &Client) -> Result<U, Error>

(Sync) Attempts to request to the API and return a new instance of the type being turned into. Read more
Source§

fn a_fetch_into<'life0, 'life1, 'async_trait>( &'life0 self, client: &'life1 Client, ) -> Pin<Box<dyn Future<Output = Result<U, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, U: 'async_trait, T: 'async_trait,

(Async) Attempts to request to the API and return a new instance of the type being turned into. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PropRouteable for T
where T: GetFetchProp,

Source§

type Property = <T as GetFetchProp>::Property

Source§

fn get_route(prop: &<T as PropRouteable>::Property) -> Route

Obtain the route for fetching by using a property.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more