mangadex_api_schema_rust/v5/
manga.rs

1use mangadex_api_types::{
2    ContentRating, Demographic, Language, MangaDexDateTime, MangaState, MangaStatus,
3    RelationshipType,
4};
5use serde::Deserialize;
6use uuid::Uuid;
7
8use crate::{
9    TypedAttributes,
10    v5::{
11        ApiObject, LocalizedString, MangaLinks, TagAttributes, language_array_or_skip_null,
12        localizedstring_array_or_map, manga_links_array_or_struct,
13    },
14};
15
16/// General manga information.
17#[derive(Debug, Deserialize, Clone, Default)]
18#[serde(rename_all = "camelCase")]
19#[non_exhaustive]
20#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
21#[cfg_attr(feature = "specta", derive(specta::Type))]
22pub struct MangaAttributes {
23    pub title: LocalizedString,
24    pub alt_titles: Vec<LocalizedString>,
25    #[serde(with = "localizedstring_array_or_map")]
26    pub description: LocalizedString,
27    // Known issue: This field isn't always returned, so default to `false` when it isn't.
28    // The decision to use the default value is to maintain compatibility if the MangaDex API
29    // fixes this by always returning this field.
30    #[serde(default)]
31    pub is_locked: bool,
32    #[serde(with = "manga_links_array_or_struct")]
33    pub links: Option<MangaLinks>,
34    pub original_language: Language,
35    pub last_volume: Option<String>,
36    pub last_chapter: Option<String>,
37    pub publication_demographic: Option<Demographic>,
38    pub status: MangaStatus,
39    pub year: Option<u16>,
40    pub content_rating: Option<ContentRating>,
41    // Known issue: This field isn't always returned, so default to `false` when it isn't.
42    // TODO: Remove the default when MangaDex always returns this field.
43    #[serde(default)]
44    pub chapter_numbers_reset_on_new_volume: bool,
45    pub latest_uploaded_chapter: Option<Uuid>,
46    // Known issue: MangaDex sometimes returns `null` as an element value, which doesn't match a possible language.
47    #[serde(with = "language_array_or_skip_null")]
48    pub available_translated_languages: Vec<Language>,
49    pub tags: Vec<ApiObject<TagAttributes>>,
50    /// The staff approval status of the manga.
51    ///
52    /// When a new manga is created with the Manga Create endpoint, it is in a "draft" state.
53    /// When it is submitted (committed), it must be approved (published) or rejected by staff.
54    ///
55    /// Manga that is in the "draft" state is not available through the search,
56    /// however, endpoints to list or retrieve the Manga Drafts are available.
57    pub state: MangaState,
58    /// Datetime in `YYYY-MM-DDTHH:MM:SS+HH:MM` format.
59    #[cfg_attr(feature = "specta", specta(type = String))]
60    #[cfg_attr(
61        feature = "serialize",
62        serde(serialize_with = "crate::v5::mangadex_datetime_serialize")
63    )]
64    pub created_at: MangaDexDateTime,
65    /// Datetime in `YYYY-MM-DDTHH:MM:SS+HH:MM` format.
66    #[cfg_attr(feature = "specta", specta(type = Option<String>))]
67    #[cfg_attr(
68        feature = "serialize",
69        serde(serialize_with = "crate::v5::mangadex_datetime_serialize_option")
70    )]
71    pub updated_at: Option<MangaDexDateTime>,
72    pub version: u32,
73}
74
75impl TypedAttributes for MangaAttributes {
76    const TYPE_: mangadex_api_types::RelationshipType = RelationshipType::Manga;
77}