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
//! Dynasty reader's chapter.

pub mod sample;

use serde::{Deserialize, Serialize};

use crate::Tag;

/// Dynasty reader's chapter.
#[derive(Debug, Deserialize, Serialize, PartialEq, Eq)]
pub struct Chapter {
    /// The chapter's title
    pub title: String,
    /// The chapter's long title
    pub long_title: String,
    /// The chapter's permalink
    pub(crate) permalink: String,
    /// The chapter's tags
    pub tags: Vec<Tag>,
    /// The chapter's pages
    pub pages: Vec<ChapterPage>,
    /// The chapter's release date
    pub released_on: String,
    /// The chapter's added date
    pub added_on: String,
}

impl Chapter {
    /// Get the chapter's absolute path from <https://dynasty-scans.com/>.
    pub fn path(&self) -> String {
        format!("chapters/{}", self.permalink)
    }
}

/// Dynasty reader's chapter page.
#[derive(Debug, Deserialize, Serialize, PartialEq, Eq)]
pub struct ChapterPage {
    /// The chapter page's title
    #[serde(rename(deserialize = "name"))]
    pub title: String,
    /// The chapter page's url
    pub(crate) url: String,
}

impl ChapterPage {
    /// Get the chapter page's absolute path from <https://dynasty-scans.com/>.
    pub fn path(&self) -> String {
        self.url.clone()
    }
}