1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use super::stat::Stat;

#[derive(Debug)]
pub enum ListResponse {
    Multiple(List),
    Single(Stat),
}

impl From<List> for ListResponse {
    fn from(list: List) -> Self {
        Self::Multiple(list)
    }
}

impl From<Stat> for ListResponse {
    fn from(item: Stat) -> Self {
        Self::Single(item)
    }
}

#[derive(Debug)]
pub struct List {
    stats: Option<Stat>,
    items: Vec<Stat>,
}

impl List {
    pub fn new(stats: Option<Stat>, items: Vec<Stat>) -> Self {
        Self { stats, items }
    }

    pub fn items(&self) -> &[Stat] {
        self.items.as_ref()
    }

    pub fn stats(&self) -> Option<&Stat> {
        self.stats.as_ref()
    }
}