ggapi/structs/
race_match_config.rs

1
2use serde::{
3    Deserialize,
4    Serialize,
5};
6
7/// Equivalent for start.gg RaceMatchConfig.
8///
9/// Each element in the structure is optional, allowing a user to only query values they want.
10/// Given each is an option and not a requirement, a method is included for each element with the same name.
11/// These methods will unwrap and return the proper value without any unwrapping or references needed.
12#[derive(Clone, Default, Serialize, Deserialize)]
13pub struct GGRaceMatchConfig {
14
15    #[serde(rename(serialize = "bracketType",               deserialize = "bracketType"))]
16    pub bracket_type:                   Option<i64>,
17    pub id:                             Option<i64>,
18
19    #[serde(rename(serialize = "playerReportingEnabled",    deserialize = "playerReportingEnabled"))]
20    pub player_reporting_enabled:       Option<bool>,
21
22    #[serde(rename(serialize = "verificationMethods",       deserialize = "verificationMethods"))]
23    pub verification_methods:           Option<Vec<i64>>,
24
25    #[serde(rename(serialize = "verificationRequired",      deserialize = "verificationRequired"))]
26    pub verification_required:          Option<bool>,
27
28}
29
30impl GGRaceMatchConfig {
31
32    /// Returns the bracket type of the race match configuration.
33    ///
34    /// Returns zero if not set or wasn't queried.
35    pub fn bracket_type(&self) -> i64 {
36        let mut result: i64 = 0;
37        if self.bracket_type.is_some() {
38            result = self.bracket_type.unwrap().clone();
39        }
40        return result;
41    }
42
43    /// Returns the id of the race match configuration.
44    ///
45    /// Returns zero if not set or wasn't queried.
46    pub fn id(&self) -> i64 {
47        let mut result: i64 = 0;
48        if self.id.is_some() {
49            result = self.id.unwrap().clone();
50        }
51        return result;
52    }
53
54    /// Returns if the race match configuration has player reporting enabled.
55    ///
56    /// Returns false if not set or wasn't queried.
57    pub fn player_reporting_enabled(&self) -> bool {
58        let mut result: bool = false;
59        if self.player_reporting_enabled.is_some() {
60            result = self.player_reporting_enabled.unwrap().clone();
61        }
62        return result;
63    }
64
65    /// Returns the verification methods of the race match configuration.
66    ///
67    /// Returns an empty vector if not set or wasn't queried.
68    pub fn verification_methods(&self) -> Vec<i64> {
69        let mut result: Vec<i64> = Vec::new();
70        if self.verification_methods.is_some() {
71            for verification_method in self.verification_methods.as_ref().unwrap() {
72                result.push(verification_method.clone());
73            }
74        }
75        return result;
76    }
77
78    /// Returns if the race match configuration has verification required.
79    ///
80    /// Returns false if not set or wasn't queried.
81    pub fn verification_required(&self) -> bool {
82        let mut result: bool = false;
83        if self.verification_required.is_some() {
84            result = self.verification_required.unwrap().clone();
85        }
86        return result;
87    }
88
89}