lotr_api/item/
attribute.rs

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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
use crate::ItemType;

/// The different attributes that can be used to sort the different items that can be retrieved
/// from the API. The contain all the attributes that are available for the different items.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum Attribute {
    Book(BookAttribute),
    Movie(MovieAttribute),
    Quote(QuoteAttribute),
    Character(CharacterAttribute),
    Chapter(ChapterAttribute),
}

impl From<Attribute> for ItemType {
    fn from(attribute: Attribute) -> Self {
        match attribute {
            Attribute::Book(_) => ItemType::Book,
            Attribute::Movie(_) => ItemType::Movie,
            Attribute::Quote(_) => ItemType::Quote,
            Attribute::Character(_) => ItemType::Character,
            Attribute::Chapter(_) => ItemType::Chapter,
        }
    }
}

impl Attribute {
    pub(crate) fn get_item_type(&self) -> ItemType {
        match self {
            Attribute::Book(_) => ItemType::Book,
            Attribute::Movie(_) => ItemType::Movie,
            Attribute::Quote(_) => ItemType::Quote,
            Attribute::Character(_) => ItemType::Character,
            Attribute::Chapter(_) => ItemType::Chapter,
        }
    }
}

#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum BookAttribute {
    Id,
    Name,
}

#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum MovieAttribute {
    Id,
    Name,
    RuntimeInMinutes,
    BudgetInMillions,
    BoxOfficeRevenueInMillions,
    AcademyAwardNominations,
    AcademyAwardWins,
    RottenTomatoesScore,
}

#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum QuoteAttribute {
    Id,
    Dialog,
    Movie,
    Character,
}

#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum CharacterAttribute {
    Id,
    Height,
    Gender,
    Birth,
    Spouse,
    Death,
    Realm,
    Hair,
    Name,
    WikiUrl,
}

#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum ChapterAttribute {
    Id,
    ChapterName,
    Book,
}