use crate::api::{DDApi, DDstatsClient, HasApiCore};
use crate::error::Result;
use crate::scheme::ddstats::{Map, Player, Profile, StatsMap, Teero};
use std::future::Future;
pub trait DDstats {
fn player(&self, player: &str) -> impl Future<Output = Result<Player>> + Send;
fn map(&self, map: &str) -> impl Future<Output = Result<Map>> + Send;
fn maps(&self) -> impl Future<Output = Result<Vec<StatsMap>>> + Send;
fn profile(&self, player: &str) -> impl Future<Output = Result<Profile>> + Send;
fn teero(&self, player: &str) -> impl Future<Output = Result<Teero>> + Send;
}
impl DDstats for DDApi {
async fn player(&self, player: &str) -> Result<Player> {
self.generator(&Player::api(player)).await
}
async fn map(&self, map: &str) -> Result<Map> {
self.generator(&Map::api(map)).await
}
async fn maps(&self) -> Result<Vec<StatsMap>> {
self.generator(&StatsMap::api()).await
}
async fn profile(&self, player: &str) -> Result<Profile> {
self.generator(&Profile::api(player)).await
}
async fn teero(&self, player: &str) -> Result<Teero> {
self.generator(&Teero::api(player)).await
}
}
impl DDstats for DDstatsClient {
async fn player(&self, player: &str) -> Result<Player> {
self.core().generator(&Player::api(player)).await
}
async fn map(&self, map: &str) -> Result<Map> {
self.core().generator(&Map::api(map)).await
}
async fn maps(&self) -> Result<Vec<StatsMap>> {
self.core().generator(&StatsMap::api()).await
}
async fn profile(&self, player: &str) -> Result<Profile> {
self.core().generator(&Profile::api(player)).await
}
async fn teero(&self, player: &str) -> Result<Teero> {
self.core().generator(&Teero::api(player)).await
}
}