lichess_api/api/
tv.rs

1use async_std::stream::StreamExt;
2
3use crate::client::LichessApi;
4use crate::error::Result;
5use crate::model::games::GameJson;
6use crate::model::tv::*;
7
8impl LichessApi<reqwest::Client> {
9    pub async fn tv_channels(&self) -> Result<Channels> {
10        self.get_single_model(channels::GetRequest::new()).await
11    }
12
13    pub async fn tv_stream_current(&self) -> Result<impl StreamExt<Item = Result<stream::Event>>> {
14        self.get_streamed_models(stream::current::GetRequest::new())
15            .await
16    }
17
18    pub async fn tv_stream_channel_current(
19        &self,
20        request: impl Into<stream::channel::GetRequest>,
21    ) -> Result<impl StreamExt<Item = Result<stream::Event>>> {
22        self.get_streamed_models(request.into()).await
23    }
24
25    pub async fn tv_channel_games(
26        &self,
27        request: impl Into<games::GetRequest>,
28    ) -> Result<impl StreamExt<Item = Result<GameJson>>> {
29        self.get_streamed_models(request.into()).await
30    }
31}