1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
pub mod lichess;
pub mod masters;
pub mod otb;
pub mod player;

use serde::{Deserialize, Serialize};

use crate::model::Color;
use crate::model::Speed;

#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[serde_with::skip_serializing_none]
pub struct OpeningExplorerJson {
    pub opening: Option<Opening>,
    pub white: u32,
    pub draws: u32,
    pub black: u32,
    pub moves: Vec<Move>,
    pub top_games: Option<Vec<Game>>,
    pub recent_games: Option<Vec<Game>>,
    pub history: Option<Vec<History>>,
    pub queue_position: Option<u32>,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Opening {
    pub eco: String,
    pub name: String,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[serde_with::skip_serializing_none]
pub struct Move {
    pub uci: String,
    pub san: String,
    pub average_rating: Option<u32>,
    pub average_opponent_rating: Option<u32>,
    pub performance: Option<u32>,
    pub white: u32,
    pub draws: u32,
    pub black: u32,
    pub game: Option<Game>,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde_with::skip_serializing_none]
pub struct Game {
    pub id: String,
    pub winner: Option<Color>,
    pub speed: Option<Speed>,
    pub mode: Option<String>,
    pub white: Player,
    pub black: Player,
    pub year: u32,
    pub month: String,
    pub uci: Option<String>,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Player {
    pub name: String,
    pub rating: u32,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct History {
    pub month: String,
    pub black: u32,
    pub draws: u32,
    pub white: u32,
}