aboutsummaryrefslogtreecommitdiff
path: root/src/models.rs
blob: 806d746d47b61da9935e65dc6ca126c4f3a5b417 (plain) (blame)
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
use relative_path::RelativePathBuf;
use serde::Deserialize;
use url::Url;

/// Generic Model for paginated API.
#[derive(Debug, serde::Deserialize)]
pub struct Paginated<T> {
    pub next: Option<Url>,
    pub results: Vec<T>,
}

/// Model for the EPUB API.
#[derive(Debug, Deserialize)]
pub struct EpubResponse {
    pub publication_date: String,
    pub title: String,
    pub descriptions: Descriptions,
    pub chapters: Url,
    pub files: Url,
    pub language: String,
}

/// Sub-model of EpubResponse - descriptions.
#[derive(Debug, Deserialize)]
pub struct Descriptions {
    #[serde(rename = "text/plain")]
    pub plain: String,
}

/// Model for chapters API.
#[derive(Debug, Deserialize)]
pub struct Chapter {
    pub ourn: String,
    pub title: String,
    pub related_assets: ChapRelAssets,
}

/// Sub-model of Chapter - related_assets.
#[derive(Debug, Deserialize)]
pub struct ChapRelAssets {
    pub stylesheets: Vec<Url>,
}

/// Model for files API.
#[derive(Debug, Deserialize)]
pub struct FileEntry {
    pub ourn: String,
    pub url: Url,
    pub full_path: RelativePathBuf,
    pub media_type: String,
    pub filename_ext: String,
}