lichess_api/api/
puzzles.rs

1use async_std::stream::StreamExt;
2
3use crate::client::LichessApi;
4use crate::error::Result;
5use crate::model::puzzles::*;
6
7impl LichessApi<reqwest::Client> {
8    pub async fn get_daily_puzzle(&self) -> Result<daily::Puzzle> {
9        self.get_single_model(daily::GetRequest::new()).await
10    }
11
12    pub async fn get_puzzle(&self, request: impl Into<id::GetRequest>) -> Result<id::Puzzle> {
13        self.get_single_model(request.into()).await
14    }
15
16    pub async fn get_new_puzzle(
17        &self,
18        request: impl Into<next::GetRequest>,
19    ) -> Result<next::Puzzle> {
20        self.get_single_model(request.into()).await
21    }
22
23    pub async fn get_puzzle_activity(
24        &self,
25        request: impl Into<activity::GetRequest>,
26    ) -> Result<impl StreamExt<Item = Result<activity::Activity>>> {
27        self.get_streamed_models(request.into()).await
28    }
29
30    pub async fn get_puzzles_to_replay(
31        &self,
32        request: impl Into<replay::GetRequest>,
33    ) -> Result<replay::Replay> {
34        self.get_single_model(request.into()).await
35    }
36
37    pub async fn get_puzzle_dashboard(
38        &self,
39        request: impl Into<dashboard::GetRequest>,
40    ) -> Result<dashboard::Dashboard> {
41        self.get_single_model(request.into()).await
42    }
43
44    pub async fn get_puzzle_storm_dashboard(
45        &self,
46        request: impl Into<storm_dashboard::GetRequest>,
47    ) -> Result<storm_dashboard::Dashboard> {
48        self.get_single_model(request.into()).await
49    }
50
51    pub async fn make_puzzle_race(
52        &self,
53        request: impl Into<race::PostRequest>,
54    ) -> Result<race::Race> {
55        self.get_single_model(request.into()).await
56    }
57}