mangadex_api_schema_rust/v5/
manga_links.rs

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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
use serde::{Deserialize, Serialize};
use url::Url;

/// Related links for a manga.
#[derive(Clone, Debug, Default, Deserialize, Hash, PartialEq, Serialize)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "non_exhaustive", non_exhaustive)]
#[cfg_attr(feature = "specta", derive(specta::Type))]
pub struct MangaLinks {
    /// Amazon Product URL.
    ///
    /// Stored as full URL.
    ///
    /// # Examples
    ///
    /// - `https://www.amazon.co.jp/gp/product/B074CHFLT2`
    #[serde(rename = "amz")]
    #[cfg_attr(feature = "specta", specta(type = Option<String>))]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub amazon: Option<Url>,

    /// AniList ID.
    ///
    /// `https://anilist.co/manga/{id}`
    ///
    /// # Examples
    ///
    /// - `112847`
    #[serde(rename = "al")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub anilist: Option<String>,

    /// Anime-Planet slug.
    ///
    /// `https://www.anime-planet.com/manga/{slug}`
    ///
    /// # Examples
    ///
    /// - `age`
    /// - `under-grand-hotel`
    #[serde(rename = "ap")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub anime_planet: Option<String>,

    /// BookWalker URI.
    ///
    /// Stored has "series/{id}".
    ///
    /// `https://bookwalker.jp/{slug}`
    ///
    /// # Examples
    ///
    /// - `series/289459`
    #[serde(rename = "bw")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub book_walker: Option<BookWalker>,
    /// CDJapan URL.
    ///
    /// Stored as full URL.
    ///
    /// # Examples
    ///
    /// - `http://www.cdjapan.co.jp/product/NEOBK-1963980`
    /// - `http://www.cdjapan.co.jp/searches?term.cat_id=UD-14-06-03&page=&agg_use=cat_ids_hierarchal_treeish_foldable&term.media_format=&f=major&q=%E7%B5%B6%E5%AF%BE%E3%81%AB%E3%81%A8%E3%81%8D%E3%82%81%E3%81%84%E3%81%A6%E3%81%AF%E3%81%84%E3%81%91%E3%81%AA%E3%81%84%EF%BC%81&f=major&q=&f=major&q=&order=scoreboost_cdj&range.rel=&range.sale_price=&term.caption=&term.audio_language=`
    #[serde(rename = "cdj")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cd_japan: Option<String>,

    /// EbookJapan URL.
    ///
    /// Stored as full URL.
    ///
    /// # Examples
    ///
    /// - `https://ebookjapan.yahoo.co.jp/books/444727/A001841690/`
    /// - `https://www.ebookjapan.jp/ebj/371654/`
    #[serde(rename = "ebj")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[cfg_attr(feature = "specta", specta(type = Option<String>))]
    pub ebook_japan: Option<Url>,

    /// Official English URL.
    ///
    /// Stored as full URL, official English-licenced URL.
    ///
    /// # Examples
    ///
    /// - `https://kodanshacomics.com/series/we-must-never-fall-in-love/`
    #[serde(rename = "engtl")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub english_translation: Option<String>,

    /// Kitsu ID.
    ///
    /// One of:
    ///
    /// - `https://kitsu.io/api/edge/manga/{id}`
    /// - `https://kitsu.io/api/edge/manga?filter[slug]={slug}`
    ///
    /// If integer, use id version of the URL, otherwise use slug one
    ///
    /// # Examples
    ///
    /// - `23040`
    #[serde(rename = "kt")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub kitsu: Option<String>,

    /// MangaUpdates ID.
    ///
    /// `https://www.mangaupdates.com/series.html?id={id}`
    ///
    /// # Examples
    ///
    /// - `157722`
    #[serde(rename = "mu")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub manga_updates: Option<MangaUpdates>,

    /// MyAnimeList ID.
    ///
    /// `https://myanimelist.net/manga/{id}`
    ///
    /// # Examples
    ///
    /// - `12648`
    #[serde(rename = "mal")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub my_anime_list: Option<MyAnimeList>,

    /// NovelUpdates slug.
    ///
    /// `https://www.novelupdates.com/series/{slug}`
    ///
    /// # Examples
    ///
    /// - `an-active-hunter-in-hokkaido-has-been-thrown-into-a-different-world`
    #[serde(rename = "nu")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub novel_updates: Option<NovelUpdates>,

    /// Raw URL.
    ///
    /// Stored as full URL, untranslated stuff URL (original language).
    ///
    /// # Examples
    ///
    /// - `https://manga.bilibili.com/m/detail/mc29443?from=manga_index`
    /// - `https://www.sunday-webry.com/detail-yoru.php?title_id=1282c`
    #[cfg_attr(feature = "specta", specta(type = Option<String>))]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub raw: Option<Url>,
}

impl MangaLinks {
    /// Check if there are no available links.
    ///
    /// This returns `false` if at least one of the fields is `Some`.
    pub(crate) fn has_no_links(&self) -> bool {
        self.amazon.is_none()
            && self.anilist.is_none()
            && self.anime_planet.is_none()
            && self.book_walker.is_none()
            && self.cd_japan.is_none()
            && self.ebook_japan.is_none()
            && self.english_translation.is_none()
            && self.kitsu.is_none()
            && self.manga_updates.is_none()
            && self.my_anime_list.is_none()
            && self.novel_updates.is_none()
            && self.raw.is_none()
    }
}

/// BookWalker URI.
///
/// Example: "`series/91701`".
#[derive(Clone, Debug, Deserialize, Hash, PartialEq, Serialize)]
#[cfg_attr(feature = "specta", derive(specta::Type))]
pub struct BookWalker(pub String);

impl std::fmt::Display for BookWalker {
    fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
        fmt.write_str(&format!("https://bookwalker.jp/{}", self.0))
    }
}

/// MangaUpdates ID.
///
/// Example: "`132515`".
#[derive(Clone, Debug, Deserialize, Hash, PartialEq, Serialize)]
#[cfg_attr(feature = "specta", derive(specta::Type))]
pub struct MangaUpdates(pub String);

impl std::fmt::Display for MangaUpdates {
    fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
        fmt.write_str(&format!(
            "https://www.mangaupdates.com/series.html?id={}",
            self.0
        ))
    }
}

/// MyAnimeList ID.
///
/// Example: "`98436`".
#[derive(Clone, Debug, Deserialize, Hash, PartialEq, Serialize)]
#[cfg_attr(feature = "specta", derive(specta::Type))]
pub struct MyAnimeList(pub String);

impl std::fmt::Display for MyAnimeList {
    fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
        fmt.write_str(&format!("https://myanimelist.net/manga/{}", self.0))
    }
}

/// NovelUpdates slug.
///
/// Example: "`novel-updates`".
#[derive(Clone, Debug, Deserialize, Hash, PartialEq, Serialize)]
#[cfg_attr(feature = "specta", derive(specta::Type))]
pub struct NovelUpdates(pub String);

impl std::fmt::Display for NovelUpdates {
    fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
        fmt.write_str(&format!("https://www.novelupdates.com/series/{}/", self.0))
    }
}