lotr_api/item/
attribute.rs

1use crate::ItemType;
2
3/// The different attributes that can be used to sort the different items that can be retrieved
4/// from the API. The contain all the attributes that are available for the different items.
5#[derive(Debug, Copy, Clone, PartialEq, Eq)]
6pub enum Attribute {
7    Book(BookAttribute),
8    Movie(MovieAttribute),
9    Quote(QuoteAttribute),
10    Character(CharacterAttribute),
11    Chapter(ChapterAttribute),
12}
13
14impl From<Attribute> for ItemType {
15    fn from(attribute: Attribute) -> Self {
16        match attribute {
17            Attribute::Book(_) => ItemType::Book,
18            Attribute::Movie(_) => ItemType::Movie,
19            Attribute::Quote(_) => ItemType::Quote,
20            Attribute::Character(_) => ItemType::Character,
21            Attribute::Chapter(_) => ItemType::Chapter,
22        }
23    }
24}
25
26impl Attribute {
27    pub(crate) fn get_item_type(&self) -> ItemType {
28        match self {
29            Attribute::Book(_) => ItemType::Book,
30            Attribute::Movie(_) => ItemType::Movie,
31            Attribute::Quote(_) => ItemType::Quote,
32            Attribute::Character(_) => ItemType::Character,
33            Attribute::Chapter(_) => ItemType::Chapter,
34        }
35    }
36}
37
38#[derive(Debug, Copy, Clone, PartialEq, Eq)]
39pub enum BookAttribute {
40    Id,
41    Name,
42}
43
44#[derive(Debug, Copy, Clone, PartialEq, Eq)]
45pub enum MovieAttribute {
46    Id,
47    Name,
48    RuntimeInMinutes,
49    BudgetInMillions,
50    BoxOfficeRevenueInMillions,
51    AcademyAwardNominations,
52    AcademyAwardWins,
53    RottenTomatoesScore,
54}
55
56#[derive(Debug, Copy, Clone, PartialEq, Eq)]
57pub enum QuoteAttribute {
58    Id,
59    Dialog,
60    Movie,
61    Character,
62}
63
64#[derive(Debug, Copy, Clone, PartialEq, Eq)]
65pub enum CharacterAttribute {
66    Id,
67    Height,
68    Gender,
69    Birth,
70    Spouse,
71    Death,
72    Realm,
73    Hair,
74    Name,
75    WikiUrl,
76}
77
78#[derive(Debug, Copy, Clone, PartialEq, Eq)]
79pub enum ChapterAttribute {
80    Id,
81    ChapterName,
82    Book,
83}