chesscom_openapi/models/
daily_game.rs

1/*
2 * Chess
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 1.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12
13
14#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
15pub struct DailyGame {
16    /// URL of the white player's profile
17    #[serde(rename = "white")]
18    pub white: String,
19    /// URL of the black player's profile
20    #[serde(rename = "black")]
21    pub black: String,
22    /// URL of this game
23    #[serde(rename = "url")]
24    pub url: String,
25    /// Current FEN
26    #[serde(rename = "fen")]
27    pub fen: String,
28    /// Current PGN
29    #[serde(rename = "pgn")]
30    pub pgn: String,
31    #[serde(rename = "turn")]
32    pub turn: crate::models::Player,
33    /// Timestamp of when the next move must be made
34    #[serde(rename = "move_by", skip_serializing_if = "Option::is_none")]
35    #[serde(with = "chrono::serde::ts_seconds_option")]
36	pub move_by: Option<chrono::DateTime<chrono::Utc>>,
37    #[serde(rename = "draw_offer", skip_serializing_if = "Option::is_none")]
38    pub draw_offer: Option<crate::models::Player>,
39    /// Timestamp of the last activity on the game
40    #[serde(rename = "last_activity")]
41    #[serde(with = "chrono::serde::ts_seconds")]
42	pub last_activity: chrono::DateTime<chrono::Utc>,
43    /// Timestamp of the game start (Daily Chess only)
44    #[serde(rename = "start_time", skip_serializing_if = "Option::is_none")]
45    #[serde(with = "chrono::serde::ts_seconds_option")]
46	pub start_time: Option<chrono::DateTime<chrono::Utc>>,
47    /// PGN-compliant time control
48    #[serde(rename = "time_control")]
49    pub time_control: String,
50    /// Time-per-move grouping, used for ratings
51    #[serde(rename = "time_class")]
52    pub time_class: TimeClass,
53    /// Game variant information (e.g., \"chess960\")
54    #[serde(rename = "rules")]
55    pub rules: Rules,
56    /// URL pointing to tournament (if available)
57    #[serde(rename = "tournament", skip_serializing_if = "Option::is_none")]
58    pub tournament: Option<String>,
59    /// URL pointing to team match (if available)
60    #[serde(rename = "match", skip_serializing_if = "Option::is_none")]
61    pub _match: Option<String>,
62}
63
64impl DailyGame {
65    pub fn new(white: String, black: String, url: String, fen: String, pgn: String, turn: crate::models::Player, last_activity: chrono::DateTime<chrono::Utc>, time_control: String, time_class: TimeClass, rules: Rules) -> DailyGame {
66        DailyGame {
67            white,
68            black,
69            url,
70            fen,
71            pgn,
72            turn,
73            move_by: None,
74            draw_offer: None,
75            last_activity,
76            start_time: None,
77            time_control,
78            time_class,
79            rules,
80            tournament: None,
81            _match: None,
82        }
83    }
84}
85
86/// Time-per-move grouping, used for ratings
87#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
88pub enum TimeClass {
89    #[serde(rename = "daily")]
90    Daily,
91    #[serde(rename = "rapid")]
92    Rapid,
93    #[serde(rename = "blitz")]
94    Blitz,
95    #[serde(rename = "bullet")]
96    Bullet,
97}
98
99impl std::fmt::Display for TimeClass {
100    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
101        match self {
102            TimeClass::Daily => write!(f, "daily"),
103            TimeClass::Rapid => write!(f, "rapid"),
104            TimeClass::Blitz => write!(f, "blitz"),
105            TimeClass::Bullet => write!(f, "bullet"),
106
107        }
108    }
109}
110
111/// Game variant information (e.g., \"chess960\")
112#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
113pub enum Rules {
114    #[serde(rename = "chess")]
115    Chess,
116    #[serde(rename = "chess960")]
117    Chess960,
118    #[serde(rename = "bughouse")]
119    Bughouse,
120    #[serde(rename = "kingofthehill")]
121    Kingofthehill,
122    #[serde(rename = "threecheck")]
123    Threecheck,
124    #[serde(rename = "crazyhouse")]
125    Crazyhouse,
126}
127
128impl std::fmt::Display for Rules {
129    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
130        match self {
131            Rules::Chess => write!(f, "chess"),
132            Rules::Chess960 => write!(f, "chess960"),
133            Rules::Bughouse => write!(f, "bughouse"),
134            Rules::Kingofthehill => write!(f, "kingofthehill"),
135            Rules::Threecheck => write!(f, "threecheck"),
136            Rules::Crazyhouse => write!(f, "crazyhouse"),
137
138        }
139    }
140}
141
142