Trait FetchFrom

Source
pub trait FetchFrom<T>: Sized {
    // Required methods
    fn fetch_from(client: &Client, value: &T) -> Result<Self>;
    fn a_fetch_from<'life0, 'life1, 'async_trait>(
        client: &'life0 Client,
        value: &'life1 T,
    ) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

A trait indicating that another type can be converted into this one by fetching from the API. Note that, thanks to a blanket implementation, implementing this implies implementing FetchInto for the other type.

Required Methods§

Source

fn fetch_from(client: &Client, value: &T) -> Result<Self>

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

§Errors

See the respective struct’s fetch implementation (or PropFetchable/PropLimFetchable implementation).

§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, value: &'life1 T, ) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

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

§Errors

See the respective struct’s a_fetch implementation (or PropFetchable/PropLimFetchable implementation).

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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§