pub struct Brawler {
pub name: String,
pub id: usize,
pub star_powers: Vec<StarPower>,
}Expand description
Contains information for a specific brawler, and allows for it to be fetched through
Brawler::fetch.
Fields§
§name: StringThe brawler’s name, in CAPS LOCK. E.g.: "SHELLY" for Shelly.
id: usizeThe 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.)
Implementations§
Source§impl Brawler
impl Brawler
Sourcepub fn get_fetch_prop(&self) -> usize
pub fn get_fetch_prop(&self) -> usize
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);Sourcepub fn fetch(client: &Client, id: usize) -> Result<Brawler>
pub fn fetch(client: &Client, id: usize) -> Result<Brawler>
(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
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.
Sourcepub async fn a_fetch(client: &Client, id: usize) -> Result<Brawler>
pub async fn a_fetch(client: &Client, id: usize) -> Result<Brawler>
(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
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§
Source§impl<'de> Deserialize<'de> for Brawler
impl<'de> Deserialize<'de> for Brawler
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl FetchFrom<BattleBrawler> for Brawler
impl FetchFrom<BattleBrawler> for Brawler
Source§fn fetch_from(client: &Client, b_brawler: &BattleBrawler) -> Result<Brawler>
fn fetch_from(client: &Client, b_brawler: &BattleBrawler) -> Result<Brawler>
(Sync) Attempts to fetch a Brawler from an existing BattleBrawler instance.
Source§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,
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,
(Async) Attempts to fetch a Brawler from an existing BattleBrawler instance.
Source§impl FetchFrom<Brawlers> for Brawler
impl FetchFrom<Brawlers> for Brawler
Source§impl FetchFrom<PlayerBrawlerStat> for Brawler
impl FetchFrom<PlayerBrawlerStat> for Brawler
Source§fn fetch_from(client: &Client, p_brawler: &PlayerBrawlerStat) -> Result<Brawler>
fn fetch_from(client: &Client, p_brawler: &PlayerBrawlerStat) -> Result<Brawler>
(Sync) Attempts to fetch a Brawler from an existing PlayerBrawlerStat instance.
Source§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,
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,
(Async) Attempts to fetch a Brawler from an existing PlayerBrawlerStat instance.
Source§impl Refetchable for Brawler
impl Refetchable for Brawler
Source§fn refetch(&self, client: &Client) -> Result<Brawler>
fn refetch(&self, client: &Client) -> Result<Brawler>
(Sync) Fetches data for this brawler again.
Source§fn a_refetch<'life0, 'life1, 'async_trait>(
&'life0 self,
client: &'life1 Client,
) -> Pin<Box<dyn Future<Output = Result<Brawler>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn a_refetch<'life0, 'life1, 'async_trait>(
&'life0 self,
client: &'life1 Client,
) -> Pin<Box<dyn Future<Output = Result<Brawler>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
(Async) Fetches data for this brawler again.
Source§fn refetch_update(&mut self, client: &Client) -> Result<&Self>
fn refetch_update(&mut self, client: &Client) -> Result<&Self>
refetch, but mutates the instance, returning an immutable reference to it. Read moreimpl Eq for Brawler
impl StructuralPartialEq for Brawler
Auto Trait Implementations§
impl Freeze for Brawler
impl RefUnwindSafe for Brawler
impl Send for Brawler
impl Sync for Brawler
impl Unpin for Brawler
impl UnwindSafe for Brawler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> FetchFrom<T> for T
impl<T> FetchFrom<T> for T
Source§fn fetch_from(_: &Client, t: &T) -> Result<T, Error>
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,
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.