aboutsummaryrefslogtreecommitdiff
path: root/src/models.rs
blob: 6035ce18ad5b7e10018b9b23080e304793ee9c1f (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
53
54
55
56
57
58
59
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<String>,
    pub results: Vec<T>,
}

/// Model for the EPUB API.
#[derive(Debug, Deserialize)]
pub struct EpubResponse {
    pub publication_date: String,
    pub title: String,
    pub chapters: String,          // This is a URL to the chapters list
    pub files: String,             // This is a URL to the resource files
    pub spine: String,             // This is a URL to the spine list
    pub table_of_contents: String, // This is a URL to the table of contents
}

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

/// 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: String,
    pub filename_ext: String,
    pub kind: String,
}

/// Model for spine API.
#[derive(Debug, Deserialize)]
pub struct SpineItem {
    pub ourn: String,
    pub reference_id: String,
    pub title: String,
}

/// Model for table of contents API.
#[derive(Debug, Deserialize)]
pub struct TocNode {
    pub depth: u32,
    pub reference_id: String,
    pub ourn: String,
    pub fragment: String,
    pub title: String,
    pub children: Vec<TocNode>,
}