async_pop/response/
list.rs

1use super::stat::Stat;
2
3#[derive(Debug)]
4pub enum ListResponse {
5    Multiple(List),
6    Single(Stat),
7}
8
9impl From<List> for ListResponse {
10    fn from(list: List) -> Self {
11        Self::Multiple(list)
12    }
13}
14
15impl From<Stat> for ListResponse {
16    fn from(item: Stat) -> Self {
17        Self::Single(item)
18    }
19}
20
21#[derive(Debug)]
22pub struct List {
23    stats: Option<Stat>,
24    items: Vec<Stat>,
25}
26
27impl List {
28    pub fn new(stats: Option<Stat>, items: Vec<Stat>) -> Self {
29        Self { stats, items }
30    }
31
32    pub fn items(&self) -> &[Stat] {
33        self.items.as_ref()
34    }
35
36    pub fn stats(&self) -> Option<&Stat> {
37        self.stats.as_ref()
38    }
39}