refactor(pixiv): keep the artwork type as the API's string

TypeModel's Illust and Manga variants existed only so serde would accept
those values -- both call sites ask a single question (is this ugoira?), so
the field is a String and the check is a comparison. Same for a type the API
adds later: it no longer fails the whole parse.
This commit is contained in:
2026-09-21 17:19:26 +08:00
parent 7dd0e8f2d6
commit 7a61077d80
3 changed files with 8 additions and 15 deletions
+4 -11
View File
@@ -10,7 +10,10 @@ pub struct IllustrationModel {
/// works (`<br />`, `<a href>`, sometimes `<p>`), empty for many.
#[serde(default)]
pub caption: String,
pub r#type: TypeModel,
/// `"illust"` / `"manga"` / `"ugoira"`; only ugoira changes how the
/// artwork is fetched (a zip of frames to encode), so the rest is kept as
/// the string the API sent rather than as variants nothing matches.
pub r#type: String,
pub image_urls: ImageUrlsModel,
pub user: UserInfoModel,
pub tags: Vec<IllustrationTagModel>,
@@ -22,16 +25,6 @@ pub struct IllustrationModel {
pub meta_pages: Vec<MetaPageModel>,
}
#[derive(Deserialize, Debug)]
pub enum TypeModel {
#[serde(rename = "illust")]
Illust,
#[serde(rename = "manga")]
Manga,
#[serde(rename = "ugoira")]
Ugoira,
}
#[derive(Deserialize, Debug)]
pub struct UserInfoModel {
pub id: u64,