Skip to main content

lichess_api/model/broadcasts/
mod.rs

1pub mod create_round;
2pub mod create_tournament;
3pub mod export_pgn;
4pub mod export_round_pgn;
5pub mod get_player;
6pub mod get_players;
7pub mod get_round;
8pub mod get_team_standings;
9pub mod get_tournament;
10pub mod list_by_user;
11pub mod list_my_rounds;
12pub mod list_official;
13pub mod push_pgn;
14pub mod reset_round;
15pub mod search;
16pub mod stream_group_pgn;
17pub mod stream_round_pgn;
18pub mod stream_tournament_pgn;
19pub mod top;
20pub mod update_round;
21pub mod update_tournament;
22
23use crate::model::{LightUser, PlayerColor, Title};
24use serde::{Deserialize, Serialize};
25use serde_with::skip_serializing_none;
26use std::collections::HashMap;
27
28#[skip_serializing_none]
29#[derive(Default, Clone, Debug, Serialize)]
30pub struct PgnStreamQuery {
31    pub clocks: Option<bool>,
32    pub comments: Option<bool>,
33}
34
35#[skip_serializing_none]
36#[derive(Clone, Debug, Deserialize, Serialize)]
37#[serde(rename_all = "camelCase")]
38pub struct BroadcastTour {
39    pub id: String,
40    pub name: String,
41    pub slug: String,
42    pub created_at: i64,
43    pub dates: Option<Vec<i64>>,
44    pub info: Option<BroadcastTourInfo>,
45    pub tier: Option<i32>,
46    pub image: Option<String>,
47    pub description: Option<String>,
48    pub team_table: Option<bool>,
49    pub show_team_scores: Option<bool>,
50    pub url: String,
51    pub community_owner: Option<LightUser>,
52}
53
54#[skip_serializing_none]
55#[derive(Default, Clone, Debug, Deserialize, Serialize)]
56#[serde(rename_all = "camelCase")]
57pub struct BroadcastTourInfo {
58    pub format: Option<String>,
59    pub tc: Option<String>,
60    #[serde(rename = "fideTC")]
61    pub fide_tc: Option<FideTimeControl>,
62    pub time_zone: Option<String>,
63    pub location: Option<String>,
64    pub players: Option<String>,
65    pub website: Option<String>,
66    pub standings: Option<String>,
67    pub regulations: Option<String>,
68}
69
70#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)]
71#[serde(rename_all = "lowercase")]
72pub enum FideTimeControl {
73    Standard,
74    Rapid,
75    Blitz,
76}
77
78#[skip_serializing_none]
79#[derive(Clone, Debug, Deserialize, Serialize)]
80#[serde(rename_all = "camelCase")]
81pub struct BroadcastRoundInfo {
82    pub id: String,
83    pub name: String,
84    pub slug: String,
85    pub created_at: i64,
86    pub rated: Option<bool>,
87    pub ongoing: Option<bool>,
88    pub starts_at: Option<i64>,
89    pub starts_after_previous: Option<bool>,
90    pub finished_at: Option<i64>,
91    #[deprecated]
92    pub finished: Option<bool>,
93    pub url: String,
94    pub delay: Option<i64>,
95    pub custom_scoring: Option<BroadcastCustomScoring>,
96}
97
98#[derive(Clone, Debug, Deserialize, Serialize)]
99#[serde(rename_all = "camelCase")]
100pub struct BroadcastCustomScoring {
101    pub white: BroadcastCustomPointsPerColor,
102    pub black: BroadcastCustomPointsPerColor,
103}
104
105#[derive(Clone, Debug, Deserialize, Serialize)]
106pub struct BroadcastCustomPointsPerColor {
107    pub win: f64,
108    pub draw: f64,
109}
110
111#[skip_serializing_none]
112#[derive(Clone, Debug, Deserialize, Serialize)]
113pub struct BroadcastRoundStudyInfo {
114    pub writeable: Option<bool>,
115    pub features: Option<BroadcastRoundStudyFeatures>,
116}
117
118#[skip_serializing_none]
119#[derive(Clone, Debug, Deserialize, Serialize)]
120pub struct BroadcastRoundStudyFeatures {
121    pub chat: Option<bool>,
122    pub computer: Option<bool>,
123    pub explorer: Option<bool>,
124}
125
126#[skip_serializing_none]
127#[derive(Clone, Debug, Deserialize, Serialize)]
128#[serde(rename_all = "camelCase")]
129pub struct BroadcastRoundGame {
130    pub id: String,
131    pub name: String,
132    pub fen: Option<String>,
133    pub players: Option<Vec<BroadcastRoundGamePlayer>>,
134    pub last_move: Option<String>,
135    pub check: Option<String>,
136    pub think_time: Option<i32>,
137    pub status: Option<String>,
138}
139
140#[skip_serializing_none]
141#[derive(Clone, Debug, Deserialize, Serialize)]
142#[serde(rename_all = "camelCase")]
143pub struct BroadcastRoundGamePlayer {
144    pub name: Option<String>,
145    pub title: Option<Title>,
146    pub rating: Option<i32>,
147    pub fide_id: Option<i32>,
148    pub fed: Option<String>,
149    pub clock: Option<i32>,
150}
151
152#[skip_serializing_none]
153#[derive(Clone, Debug, Deserialize, Serialize)]
154pub struct BroadcastGroup {
155    pub id: String,
156    pub slug: String,
157    pub name: String,
158    pub tours: Vec<BroadcastGroupTour>,
159}
160
161#[derive(Clone, Debug, Deserialize, Serialize)]
162pub struct BroadcastGroupTour {
163    pub id: String,
164    pub name: String,
165    pub active: bool,
166    pub live: bool,
167}
168
169pub type BroadcastPhotos = HashMap<String, BroadcastPhoto>;
170
171#[skip_serializing_none]
172#[derive(Clone, Debug, Deserialize, Serialize)]
173pub struct BroadcastPhoto {
174    pub small: String,
175    pub medium: String,
176    pub credit: Option<String>,
177}
178
179#[skip_serializing_none]
180#[derive(Clone, Debug, Deserialize, Serialize)]
181#[serde(rename_all = "camelCase")]
182pub struct BroadcastRound {
183    pub round: BroadcastRoundInfo,
184    pub tour: BroadcastTour,
185    pub study: BroadcastRoundStudyInfo,
186    pub games: Vec<BroadcastRoundGame>,
187    pub group: Option<BroadcastGroup>,
188    pub is_subscribed: Option<bool>,
189    pub photos: BroadcastPhotos,
190}
191
192#[skip_serializing_none]
193#[derive(Clone, Debug, Deserialize, Serialize)]
194pub struct BroadcastRoundNew {
195    pub round: BroadcastRoundInfo,
196    pub tour: BroadcastTour,
197    pub study: BroadcastRoundStudyInfo,
198}
199
200#[skip_serializing_none]
201#[derive(Clone, Debug, Deserialize, Serialize)]
202pub struct BroadcastMyRound {
203    pub round: BroadcastRoundInfo,
204    pub tour: BroadcastTour,
205    pub study: BroadcastRoundStudyInfo,
206}
207
208#[skip_serializing_none]
209#[derive(Clone, Debug, Deserialize, Serialize)]
210#[serde(rename_all = "camelCase")]
211pub struct BroadcastWithRounds {
212    pub tour: BroadcastTour,
213    pub group: Option<String>,
214    pub rounds: Vec<BroadcastRoundInfo>,
215    pub default_round_id: Option<String>,
216    pub photos: Option<BroadcastPhotos>,
217}
218
219#[skip_serializing_none]
220#[derive(Clone, Debug, Deserialize, Serialize)]
221#[serde(rename_all = "camelCase")]
222pub struct BroadcastWithRoundsAndFullGroup {
223    pub tour: BroadcastTour,
224    pub group: Option<BroadcastGroup>,
225    pub rounds: Vec<BroadcastRoundInfo>,
226    pub default_round_id: Option<String>,
227    pub photos: Option<BroadcastPhotos>,
228}
229
230#[skip_serializing_none]
231#[derive(Clone, Debug, Deserialize, Serialize)]
232pub struct BroadcastWithLastRound {
233    pub group: Option<String>,
234    pub tour: Option<BroadcastTour>,
235    pub round: Option<BroadcastRoundInfo>,
236}
237
238#[skip_serializing_none]
239#[derive(Clone, Debug, Deserialize, Serialize)]
240pub struct BroadcastByUser {
241    pub tour: BroadcastTour,
242}
243
244#[derive(Clone, Debug, Deserialize, Serialize)]
245#[serde(rename_all = "camelCase")]
246pub struct BroadcastTop {
247    pub active: Vec<BroadcastWithLastRound>,
248    pub past: BroadcastPaginator<BroadcastWithLastRound>,
249}
250
251#[derive(Clone, Debug, Deserialize, Serialize)]
252#[serde(rename_all = "camelCase")]
253pub struct BroadcastPaginator<T> {
254    pub current_page: u32,
255    pub max_per_page: u32,
256    pub current_page_results: Vec<T>,
257    pub previous_page: Option<u32>,
258    pub next_page: Option<u32>,
259    #[serde(skip_serializing_if = "Option::is_none")]
260    pub nb_results: Option<u32>,
261    #[serde(skip_serializing_if = "Option::is_none")]
262    pub nb_pages: Option<u32>,
263}
264
265pub type BroadcastByUserPaginator = BroadcastPaginator<BroadcastByUser>;
266
267#[derive(Clone, Debug, Deserialize, Serialize)]
268pub struct BroadcastSearchResult {
269    pub tour: BroadcastTour,
270    pub round: BroadcastRoundInfo,
271}
272
273pub type BroadcastSearchPaginator = BroadcastPaginator<BroadcastSearchResult>;
274
275#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)]
276pub enum BroadcastPointStr {
277    #[serde(rename = "1")]
278    Win,
279    #[serde(rename = "1/2")]
280    Draw,
281    #[serde(rename = "0")]
282    Loss,
283}
284
285#[skip_serializing_none]
286#[derive(Clone, Debug, Deserialize, Serialize)]
287#[serde(rename_all = "camelCase")]
288pub struct BroadcastPlayerWithFed {
289    pub name: String,
290    pub title: Option<Title>,
291    pub rating: Option<i32>,
292    pub fide_id: Option<i64>,
293    pub team: Option<String>,
294    pub fed: Option<String>,
295}
296
297#[skip_serializing_none]
298#[derive(Clone, Debug, Deserialize, Serialize)]
299#[serde(rename_all = "camelCase")]
300pub struct StatByFideTC {
301    pub standard: Option<i32>,
302    pub rapid: Option<i32>,
303    pub blitz: Option<i32>,
304}
305
306#[skip_serializing_none]
307#[derive(Clone, Debug, Deserialize, Serialize)]
308#[serde(rename_all = "camelCase")]
309pub struct BroadcastPlayerTiebreak {
310    pub extended_code: BroadcastTiebreakExtendedCode,
311    pub description: String,
312    pub points: f64,
313}
314
315#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)]
316pub enum BroadcastTiebreakExtendedCode {
317    #[serde(rename = "AOB")]
318    Aob,
319    #[serde(rename = "APPO")]
320    Appo,
321    #[serde(rename = "APRO")]
322    Apro,
323    #[serde(rename = "ARO")]
324    Aro,
325    #[serde(rename = "ARO-C1")]
326    AroC1,
327    #[serde(rename = "ARO-C2")]
328    AroC2,
329    #[serde(rename = "ARO-M1")]
330    AroM1,
331    #[serde(rename = "ARO-M2")]
332    AroM2,
333    #[serde(rename = "BH")]
334    Bh,
335    #[serde(rename = "BH-C1")]
336    BhC1,
337    #[serde(rename = "BH-C2")]
338    BhC2,
339    #[serde(rename = "BH-M1")]
340    BhM1,
341    #[serde(rename = "BH-M2")]
342    BhM2,
343    #[serde(rename = "BPG")]
344    Bpg,
345    #[serde(rename = "BWG")]
346    Bwg,
347    #[serde(rename = "DE")]
348    De,
349    #[serde(rename = "FB")]
350    Fb,
351    #[serde(rename = "FB-C1")]
352    FbC1,
353    #[serde(rename = "FB-C2")]
354    FbC2,
355    #[serde(rename = "FB-M1")]
356    FbM1,
357    #[serde(rename = "FB-M2")]
358    FbM2,
359    #[serde(rename = "KS")]
360    Ks,
361    #[serde(rename = "PS")]
362    Ps,
363    #[serde(rename = "PS-C1")]
364    PsC1,
365    #[serde(rename = "PS-C2")]
366    PsC2,
367    #[serde(rename = "PS-M1")]
368    PsM1,
369    #[serde(rename = "PS-M2")]
370    PsM2,
371    #[serde(rename = "PTP")]
372    Ptp,
373    #[serde(rename = "SB")]
374    Sb,
375    #[serde(rename = "SB-C1")]
376    SbC1,
377    #[serde(rename = "SB-C2")]
378    SbC2,
379    #[serde(rename = "SB-M1")]
380    SbM1,
381    #[serde(rename = "SB-M2")]
382    SbM2,
383    #[serde(rename = "TPR")]
384    Tpr,
385    #[serde(rename = "WON")]
386    Won,
387}
388
389#[skip_serializing_none]
390#[derive(Clone, Debug, Deserialize, Serialize)]
391#[serde(rename_all = "camelCase")]
392pub struct BroadcastPlayerEntry {
393    pub name: String,
394    pub title: Option<Title>,
395    pub rating: Option<i32>,
396    pub fide_id: Option<i64>,
397    pub team: Option<String>,
398    pub fed: Option<String>,
399    pub score: Option<f64>,
400    pub played: Option<i32>,
401    pub rating_diffs: Option<StatByFideTC>,
402    pub ratings_map: Option<StatByFideTC>,
403    pub performances: Option<StatByFideTC>,
404    pub tiebreaks: Option<Vec<BroadcastPlayerTiebreak>>,
405    pub rank: Option<i32>,
406}
407
408#[skip_serializing_none]
409#[derive(Clone, Debug, Deserialize, Serialize)]
410pub struct BroadcastPlayerFideInfo {
411    pub year: Option<i32>,
412    pub ratings: Option<StatByFideTC>,
413}
414
415#[skip_serializing_none]
416#[derive(Clone, Debug, Deserialize, Serialize)]
417#[serde(rename_all = "camelCase")]
418pub struct BroadcastPlayerEntryWithFideAndGames {
419    pub name: String,
420    pub title: Option<Title>,
421    pub rating: Option<i32>,
422    pub fide_id: Option<i64>,
423    pub team: Option<String>,
424    pub fed: Option<String>,
425    pub score: Option<f64>,
426    pub played: Option<i32>,
427    pub rating_diffs: Option<StatByFideTC>,
428    pub ratings_map: Option<StatByFideTC>,
429    pub performances: Option<StatByFideTC>,
430    pub tiebreaks: Option<Vec<BroadcastPlayerTiebreak>>,
431    pub rank: Option<i32>,
432    pub fide: Option<BroadcastPlayerFideInfo>,
433    pub games: Option<Vec<BroadcastGameEntry>>,
434}
435
436#[skip_serializing_none]
437#[derive(Clone, Debug, Deserialize, Serialize)]
438#[serde(rename_all = "camelCase")]
439pub struct BroadcastGameEntry {
440    pub round: String,
441    pub id: String,
442    pub opponent: BroadcastPlayerWithFed,
443    pub color: PlayerColor,
444    pub points: Option<BroadcastPointStr>,
445    pub custom_points: Option<f64>,
446    pub rating_diff: Option<i32>,
447    #[serde(rename = "fideTC")]
448    pub fide_tc: FideTimeControl,
449    pub ongoing: Option<bool>,
450}
451
452#[skip_serializing_none]
453#[derive(Clone, Debug, Deserialize, Serialize)]
454#[serde(rename_all = "camelCase")]
455pub struct BroadcastTeamLeaderboardEntry {
456    pub name: String,
457    pub mp: f64,
458    pub gp: f64,
459    pub average_rating: Option<i32>,
460    pub matches: Vec<BroadcastTeamPovMatchEntry>,
461    pub players: Vec<BroadcastPlayerEntry>,
462}
463
464#[skip_serializing_none]
465#[derive(Clone, Debug, Deserialize, Serialize)]
466#[serde(rename_all = "camelCase")]
467pub struct BroadcastTeamPovMatchEntry {
468    pub round_id: String,
469    pub opponent: String,
470    pub mp: Option<f64>,
471    pub gp: Option<f64>,
472    pub points: Option<BroadcastPointStr>,
473}
474
475#[skip_serializing_none]
476#[derive(Clone, Debug, Deserialize, Serialize)]
477pub struct BroadcastPgnPush {
478    pub games: Vec<BroadcastPgnPushGame>,
479}
480
481#[skip_serializing_none]
482#[derive(Clone, Debug, Deserialize, Serialize)]
483pub struct BroadcastPgnPushGame {
484    pub tags: HashMap<String, String>,
485    pub moves: Option<i32>,
486    pub error: Option<String>,
487}