1use crate::api::DDApi;
2use crate::errors::ApiError;
3use crate::scheme::ddnet::*;
4use std::future::Future;
5
6#[allow(dead_code)]
7pub trait DDnetApi {
8 fn master(&self) -> impl Future<Output = Result<Master, ApiError>> + Send;
9 fn custom_master(
10 &self,
11 master: MasterServer,
12 ) -> impl Future<Output = Result<Master, ApiError>> + Send;
13 fn player(&self, player: &str) -> impl Future<Output = Result<Player, ApiError>> + Send;
14 fn query(&self, player: &str) -> impl Future<Output = Result<Vec<Query>, ApiError>> + Send;
15 fn map(&self, map: &str) -> impl Future<Output = Result<Map, ApiError>> + Send;
16 fn releases_map(&self) -> impl Future<Output = Result<Vec<ReleasesMaps>, ApiError>> + Send;
17 fn status(&self) -> impl Future<Output = Result<Status, ApiError>> + Send;
18}
19
20impl DDnetApi for DDApi {
21 async fn master(&self) -> Result<Master, ApiError> {
22 self.custom_master(MasterServer::One).await
23 }
24
25 async fn custom_master(&self, master: MasterServer) -> Result<Master, ApiError> {
26 self._generator(&Master::api(master)).await
27 }
28
29 async fn player(&self, player: &str) -> Result<Player, ApiError> {
30 self._generator(&Player::api(player)).await
31 }
32 async fn query(&self, player: &str) -> Result<Vec<Query>, ApiError> {
33 self._generator(&Query::api(player)).await
34 }
35
36 async fn map(&self, map: &str) -> Result<Map, ApiError> {
37 self._generator(&Map::api(map)).await
38 }
39 async fn releases_map(&self) -> Result<Vec<ReleasesMaps>, ApiError> {
40 self._generator(&ReleasesMaps::api()).await
41 }
42
43 async fn status(&self) -> Result<Status, ApiError> {
44 self._generator(&Status::api()).await
45 }
46}