asoiaf_api/requester/
filter.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
use super::ToUrl;

pub enum BookFilter {
    Name(String),
    FromReleaseDate(String),
    ToReleaseDate(String),
}

impl ToUrl for BookFilter {
    fn to_url(&self) -> String {
        match self {
            BookFilter::Name(name) => format!("name={name}",),
            BookFilter::FromReleaseDate(date) => format!("fromReleaseDate={date}"),
            BookFilter::ToReleaseDate(date) => format!("toReleaseDate={date}"),
        }
    }
}

pub enum CharacterFilter {
    Name(String),
    Gender(String),
    Culture(String),
    Born(String),
    Died(String),
    IsAlive(bool),
}

impl ToUrl for CharacterFilter {
    fn to_url(&self) -> String {
        match self {
            CharacterFilter::Name(name) => format!("name={name}"),
            CharacterFilter::Gender(gender) => format!("gender={gender}"),
            CharacterFilter::Culture(culture) => format!("culture={culture}"),
            CharacterFilter::Born(born) => format!("born={born}"),
            CharacterFilter::Died(died) => format!("died={died}"),
            CharacterFilter::IsAlive(is_alive) => format!("isAlive={is_alive}"),
        }
    }
}

pub enum HouseFilter {
    Name(String),
    Region(String),
    Words(String),
    HasWords(bool),
    HasTitles(bool),
    HasSeats(bool),
    HasDiedOut(bool),
    HasAncestralWeapons(bool),
}

impl ToUrl for HouseFilter {
    fn to_url(&self) -> String {
        match self {
            HouseFilter::Name(name) => format!("name={name}"),
            HouseFilter::Region(name) => format!("region={name}"),
            HouseFilter::Words(name) => format!("words={name}"),
            HouseFilter::HasWords(name) => format!("hasWords={name}"),
            HouseFilter::HasTitles(name) => format!("hasTitles={name}"),
            HouseFilter::HasSeats(name) => format!("hasSeats={name}"),
            HouseFilter::HasDiedOut(name) => format!("hasDiedOut={name}"),
            HouseFilter::HasAncestralWeapons(name) => format!("hasAncestralWeapons={name}"),
        }
    }
}