Struct Brawler

Source
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: 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.)

Implementations§

Source§

impl Brawler

Source

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);
Source

pub fn get_route(id: usize) -> Route

Returns the Route object required for fetching a Brawler instance.

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

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

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

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 Clone for Brawler

Source§

fn clone(&self) -> Brawler

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Brawler

Source§

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

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

impl Default for Brawler

Source§

fn default() -> Brawler

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![]
    }
);
Source§

impl<'de> Deserialize<'de> for Brawler

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 FetchFrom<BattleBrawler> for Brawler

Source§

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,

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

Source§

impl FetchFrom<Brawlers> for Brawler

Source§

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

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

Source§

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,

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

Source§

impl FetchFrom<PlayerBrawlerStat> for Brawler

Source§

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,

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

Source§

impl Hash for Brawler

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 Brawler

Source§

fn eq(&self, other: &Brawler) -> 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 Refetchable for Brawler

Source§

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,

(Async) Fetches data for this brawler again.

Source§

fn refetch_update(&mut self, client: &Client) -> Result<&Self>

(Sync) Like refetch, but mutates the instance, returning an immutable reference to it. Read more
Source§

fn a_refetch_update<'life0, 'async_trait>( &'async_trait mut self, client: &'life0 Client, ) -> Pin<Box<dyn Future<Output = Result<&'async_trait Self>> + Send + 'async_trait>>
where Self: Send + Sync + Send + 'async_trait, 'life0: 'async_trait,

(Async) Like a_refetch, but mutates the instance, returning an immutable reference to it. Read more
Source§

impl Serialize for Brawler

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 Eq for Brawler

Source§

impl StructuralPartialEq for Brawler

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

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