mangadex_api_schema_rust/v5/
chapter.rs

1use serde::Deserialize;
2use url::Url;
3use uuid::Uuid;
4
5use crate::deserialize_null_default;
6use mangadex_api_types::{Language, MangaDexDateTime};
7
8/// General chapter information.
9/// More details at <https://api.mangadex.org/docs/swagger.html#model-ChapterAttributes>
10#[derive(Clone, Debug, Deserialize, PartialEq)]
11#[serde(rename_all = "camelCase")]
12#[cfg_attr(feature = "non_exhaustive", non_exhaustive)]
13#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
14#[cfg_attr(feature = "specta", derive(specta::Type))]
15pub struct ChapterAttributes {
16    // TODO: Known issue: API doesn't always return an empty string despite the docs saying it's not nullable.
17    #[serde(deserialize_with = "deserialize_null_default")]
18    pub title: Option<String>,
19    /// Volume number in the manga.
20    pub volume: Option<String>,
21    /// Chapter number in the manga.
22    pub chapter: Option<String>,
23    /// Count of readable images for this chapter.
24    pub pages: u32,
25    /// Language the text is in.
26    pub translated_language: Language,
27    #[serde(skip_serializing_if = "Option::is_none")]
28    pub uploader: Option<Uuid>,
29    /// Denotes a chapter that links to an external source.
30    pub external_url: Option<Url>,
31    pub version: u32,
32    /// Datetime in `YYYY-MM-DDTHH:MM:SS+HH:MM` format.
33    #[cfg_attr(
34        feature = "serialize",
35        serde(serialize_with = "crate::v5::mangadex_datetime_serialize")
36    )]
37    pub created_at: MangaDexDateTime,
38    /// Datetime in `YYYY-MM-DDTHH:MM:SS+HH:MM` format.
39    #[cfg_attr(
40        feature = "serialize",
41        serde(serialize_with = "crate::v5::mangadex_datetime_serialize_option")
42    )]
43    pub updated_at: Option<MangaDexDateTime>,
44    /// Datetime in `YYYY-MM-DDTHH:MM:SS+HH:MM` format.
45    #[cfg_attr(feature = "specta", specta(type = String))]
46    #[cfg_attr(
47        feature = "serialize",
48        serde(serialize_with = "crate::v5::mangadex_datetime_serialize_option")
49    )]
50    pub publish_at: Option<MangaDexDateTime>,
51    /// Datetime in `YYYY-MM-DDTHH:MM:SS+HH:MM` format.
52    #[cfg_attr(feature = "specta", specta(type = String))]
53    #[cfg_attr(
54        feature = "serialize",
55        serde(serialize_with = "crate::v5::mangadex_datetime_serialize_option")
56    )]
57    pub readable_at: Option<MangaDexDateTime>,
58}