speedrun_api/api/
common.rs

1use serde::Serialize;
2
3/// Sort direction
4#[derive(Debug, Serialize, Clone, Copy)]
5#[serde(rename_all = "kebab-case")]
6pub enum Direction {
7    /// Sort ascending
8    Asc,
9    /// Sort descending
10    Desc,
11}
12
13/// Sorting options for variables
14#[derive(Debug, Serialize, Clone, Copy)]
15#[serde(rename_all = "kebab-case")]
16pub enum VariablesSorting {
17    /// Sorts alphanumerically by the variable name
18    Name,
19    /// Sorts by `mandatory` flag
20    Mandatory,
21    /// Sorts by `user-defined` flag
22    UserDefined,
23    /// Sorts by the order defined by the game moderator (default)
24    Pos,
25}
26
27/// Sorting options for categories
28#[derive(Debug, Serialize, Clone, Copy)]
29#[serde(rename_all = "kebab-case")]
30pub enum CategoriesSorting {
31    /// Sort alphanumerically by category name
32    Name,
33    /// Sort by `miscellaneous` flag
34    Miscellaneous,
35    /// Use sort order defined by game moderator (default)
36    Pos,
37}
38
39impl Default for VariablesSorting {
40    fn default() -> Self {
41        Self::Pos
42    }
43}
44
45impl Default for CategoriesSorting {
46    fn default() -> Self {
47        Self::Pos
48    }
49}