chesscom_openapi/models/
player_result.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 PlayerResult {
16    #[serde(rename = "username")]
17    pub username: String,
18    /// The player's rating at the start of the game
19    #[serde(rename = "rating")]
20    pub rating: i32,
21    /// Player result:  * `win` - Win  * `checkmated` - Checkmated  * `agreed` - Draw agreed  * `repetition` - Draw by repetition  * `timeout` - Timeout  * `resigned` - Resigned  * `stalemate` - Stalemate  * `lose` - Lose  * `insufficient` - Insufficient material  * `50` - Draw by 50-move rule  * `abandoned` - abandoned  * `kingofthehill` - Opponent king reached the hill  * `threecheck` - Checked for the 3rd time  * `timevsinsufficient` - Draw by timeout vs insufficient material  * `bughousepartnerlose` - Bughouse partner lost 
22    #[serde(rename = "result")]
23    pub result: Result,
24    /// URL of this player's profile
25    #[serde(rename = "@id")]
26    pub id: String,
27}
28
29impl PlayerResult {
30    pub fn new(username: String, rating: i32, result: Result, id: String) -> PlayerResult {
31        PlayerResult {
32            username,
33            rating,
34            result,
35            id,
36        }
37    }
38}
39
40/// Player result:  * `win` - Win  * `checkmated` - Checkmated  * `agreed` - Draw agreed  * `repetition` - Draw by repetition  * `timeout` - Timeout  * `resigned` - Resigned  * `stalemate` - Stalemate  * `lose` - Lose  * `insufficient` - Insufficient material  * `50` - Draw by 50-move rule  * `abandoned` - abandoned  * `kingofthehill` - Opponent king reached the hill  * `threecheck` - Checked for the 3rd time  * `timevsinsufficient` - Draw by timeout vs insufficient material  * `bughousepartnerlose` - Bughouse partner lost 
41#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
42pub enum Result {
43    #[serde(rename = "win")]
44    Win,
45    #[serde(rename = "checkmated")]
46    Checkmated,
47    #[serde(rename = "agreed")]
48    Agreed,
49    #[serde(rename = "repetition")]
50    Repetition,
51    #[serde(rename = "timeout")]
52    Timeout,
53    #[serde(rename = "resigned")]
54    Resigned,
55    #[serde(rename = "stalemate")]
56    Stalemate,
57    #[serde(rename = "lose")]
58    Lose,
59    #[serde(rename = "insufficient")]
60    Insufficient,
61    #[serde(rename = "50move")]
62    _50move,
63    #[serde(rename = "abandoned")]
64    Abandoned,
65    #[serde(rename = "kingofthehill")]
66    Kingofthehill,
67    #[serde(rename = "threecheck")]
68    Threecheck,
69    #[serde(rename = "timevsinsufficient")]
70    Timevsinsufficient,
71    #[serde(rename = "bughousepartnerlose")]
72    Bughousepartnerlose,
73}
74
75impl std::fmt::Display for Result {
76    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
77        match self {
78            Result::Win => write!(f, "win"),
79            Result::Checkmated => write!(f, "checkmated"),
80            Result::Agreed => write!(f, "agreed"),
81            Result::Repetition => write!(f, "repetition"),
82            Result::Timeout => write!(f, "timeout"),
83            Result::Resigned => write!(f, "resigned"),
84            Result::Stalemate => write!(f, "stalemate"),
85            Result::Lose => write!(f, "lose"),
86            Result::Insufficient => write!(f, "insufficient"),
87            Result::_50move => write!(f, "50move"),
88            Result::Abandoned => write!(f, "abandoned"),
89            Result::Kingofthehill => write!(f, "kingofthehill"),
90            Result::Threecheck => write!(f, "threecheck"),
91            Result::Timevsinsufficient => write!(f, "timevsinsufficient"),
92            Result::Bughousepartnerlose => write!(f, "bughousepartnerlose"),
93
94        }
95    }
96}
97
98