pub trait Refetchable: Sized {
// Required methods
fn refetch(&self, client: &Client) -> Result<Self>;
fn a_refetch<'life0, 'life1, 'async_trait>(
&'life0 self,
client: &'life1 Client,
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn refetch_update(&mut self, client: &Client) -> Result<&Self> { ... }
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 { ... }
}Expand description
A trait representing a type whose instance can be fetched again.
Note that all types implementing GetFetchProp and PropFetchable also implement
Refetchable due to a blanket implementation.
Required Methods§
Sourcefn refetch(&self, client: &Client) -> Result<Self>
fn refetch(&self, client: &Client) -> Result<Self>
(Sync) Causes this instance to be re-fetched (i.e., updated to latest Brawl Stars data).
§Examples
use brawl_api::prelude::*;
let my_client = Client::new("my auth key");
let player = Player::fetch(&my_client, "#PLAYER_TAG_HERE")?;
// after using it a bit, we want to update its data
let player = player.refetch(&my_client)?; // `refetch` does not mutate the instance!
// player variable is now up-to-date.
Sourcefn a_refetch<'life0, 'life1, 'async_trait>(
&'life0 self,
client: &'life1 Client,
) -> Pin<Box<dyn Future<Output = Result<Self>> + 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<Self>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
(Async) Causes this instance to be re-fetched (i.e., updated to latest Brawl Stars data).
§Examples
use brawl_api::prelude::*;
let my_client = Client::new("my auth key");
let player = Player::a_fetch(&my_client, "#PLAYER_TAG_HERE").await?;
// after using it a bit, we want to update its data
let player = player.a_refetch(&my_client).await?; // this does not mutate the old instance!
// player variable is now up-to-date.
Provided Methods§
Sourcefn refetch_update(&mut self, client: &Client) -> Result<&Self>
fn refetch_update(&mut self, client: &Client) -> Result<&Self>
(Sync) Like refetch, but mutates the instance, returning an immutable reference to it.
Its usage and errors are the same (it is called, after all), but the old variable does not need to be assigned; rather, that is done for the programmer (the variable’s value is entirely replaced by a new one, if the fetching is successful).
Sourcefn 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>>
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>>
(Async) Like a_refetch, but mutates the instance, returning an immutable reference to it.
Its usage and errors are the same (it is called, after all), but the old variable does not need to be assigned; rather, that is done for the programmer (the variable’s value is entirely replaced by a new one, if the fetching is successful).
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.