brawl_api/model/
common.rs

1//! Models shared for usage by more than one endpoint. Note that, if all the relevant endpoints'
2//! features are disabled, then the respective models here are also disabled.
3
4use serde::{self, Serialize, Deserialize};
5
6/// A struct representing a brawler's star power. Note that, if **both** `players` and `brawlers`
7/// features are turned off, then this struct is also removed (it is required by both, so if neither
8/// are enabled anymore, this isn't either).
9#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)]
10#[cfg(any(feature = "players", feature = "brawlers"))]
11pub struct StarPower {
12
13    /// The star power name.
14    #[serde(default)]
15    pub name: String,
16
17    /// The star power's id (an arbitrary number).
18    #[serde(default)]
19    pub id: usize
20}
21
22impl Default for StarPower {
23
24    /// Returns an instance of `StarPower` with initial values.
25    ///
26    /// # Examples
27    ///
28    /// ```rust
29    /// use brawl_api::StarPower;
30    ///
31    /// assert_eq!(
32    ///     StarPower::default(),
33    ///     StarPower {
34    ///         name: String::from(""),
35    ///         id: 0,
36    ///     }
37    /// );
38    /// ```
39    fn default() -> StarPower {
40        StarPower {
41            name: String::from(""),
42            id: 0
43        }
44    }
45}