mango_api/requests/
chapter.rs

1//! Utilities for chapter specific server part of the application.
2//!
3//! The meaning of most of the confusing structs here can be found at <https://api.mangadex.org/docs/3-enumerations/#manga-links-data>
4//!
5//! All queries encountered here can be constructed with the builder syntax from the [bon] crate
6
7use serde::{Deserialize, Serialize};
8
9use super::query_utils::Relationship;
10use super::{Entity, EntityType, Locale};
11
12/// Used for serialization/deserialization
13#[derive(Serialize, Deserialize, Debug, Clone)]
14#[serde(rename_all = "camelCase")]
15pub struct ChapterAttributes {
16    pub title: Option<String>,
17    pub volume: Option<String>,
18    pub chapter: Option<String>,
19    pub pages: usize,
20    pub translated_language: Locale,
21    pub uploader: Option<String>,
22    pub external_url: Option<String>,
23    pub version: usize,
24    pub created_at: String,
25    pub updated_at: String,
26    pub publish_at: String,
27    pub readable_at: String,
28}
29
30/// Main structure used for representing the response containg chapter info
31#[derive(Serialize, Deserialize, Debug, Clone)]
32pub struct Chapter {
33    pub id: String,
34    #[serde(rename = "type")]
35    pub entity_type: EntityType,
36    pub attributes: ChapterAttributes,
37    pub relationships: Vec<Relationship>,
38}
39
40impl Entity for Chapter {}
41
42/// Main structure used for representing the response containg chapter meta info
43#[derive(Serialize, Deserialize, Debug, Clone)]
44#[serde(rename_all = "camelCase")]
45pub struct ChapterMeta {
46    pub hash: String,
47    pub data: Vec<String>,
48    pub data_saver: Vec<String>,
49}
50
51/// Main structure used for representing the response containg chapter download meta info
52#[derive(Serialize, Deserialize, Debug, Clone)]
53#[serde(rename_all = "camelCase")]
54pub struct ChapterDownloadMeta {
55    pub result: String,
56    pub base_url: String,
57    pub chapter: ChapterMeta,
58}