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 skins(&self) -> impl Future<Output = Result<DDSkins, ApiError>> + Send;
10 fn custom_master(
11 &self,
12 master: MasterServer,
13 ) -> impl Future<Output = Result<Master, ApiError>> + Send;
14 fn player(&self, player: &str) -> impl Future<Output = Result<Player, ApiError>> + Send;
15 fn query(&self, player: &str) -> impl Future<Output = Result<Vec<Query>, ApiError>> + Send;
16 fn query_map(
17 &self,
18 player: &str,
19 ) -> impl Future<Output = Result<Vec<QueryMap>, ApiError>> + Send;
20 fn query_mapper(
21 &self,
22 player: &str,
23 ) -> impl Future<Output = Result<Vec<QueryMapper>, ApiError>> + Send;
24 fn map(&self, map: &str) -> impl Future<Output = Result<Map, ApiError>> + Send;
25 fn releases_map(&self) -> impl Future<Output = Result<Vec<ReleasesMaps>, ApiError>> + Send;
26 fn status(&self) -> impl Future<Output = Result<Status, ApiError>> + Send;
27}
28
29impl DDnetApi for DDApi {
30 async fn master(&self) -> Result<Master, ApiError> {
31 self.custom_master(MasterServer::One).await
32 }
33
34 async fn skins(&self) -> Result<DDSkins, ApiError> {
35 self._generator(&DDSkins::api()).await
36 }
37
38 async fn custom_master(&self, master: MasterServer) -> Result<Master, ApiError> {
39 self._generator(&Master::api(master)).await
40 }
41
42 async fn player(&self, player: &str) -> Result<Player, ApiError> {
43 self._generator(&Player::api(player)).await
44 }
45 async fn query(&self, player: &str) -> Result<Vec<Query>, ApiError> {
46 self._generator(&Query::api(player)).await
47 }
48
49 async fn query_map(&self, player: &str) -> Result<Vec<QueryMap>, ApiError> {
50 self._generator(&QueryMap::api(player)).await
51 }
52
53 async fn query_mapper(&self, player: &str) -> Result<Vec<QueryMapper>, ApiError> {
54 self._generator(&QueryMapper::api(player)).await
55 }
56
57 async fn map(&self, map: &str) -> Result<Map, ApiError> {
58 self._generator(&Map::api(map)).await
59 }
60 async fn releases_map(&self) -> Result<Vec<ReleasesMaps>, ApiError> {
61 self._generator(&ReleasesMaps::api()).await
62 }
63
64 async fn status(&self) -> Result<Status, ApiError> {
65 self._generator(&Status::api()).await
66 }
67}