vndb_api/format/
release.rs

1use crate::format::producer::*;
2use crate::format::schema::{Language, Medium, Platform};
3use crate::format::vn::*;
4use serde::{Deserialize, Serialize};
5use serde_repr::*;
6
7#[derive(Deserialize, Serialize, Debug)]
8pub struct Release {
9    /// Vndbid
10    pub id: Option<String>,
11    /// Main title as displayed on the site typically romanized from the original script
12    pub title: Option<String>,
13    /// Alternative title typically the same as title but in the original script
14    pub alttitle: Option<String>,
15    /// Languages this release is available in
16    pub languages: Option<Vec<ReleaseLanguage>>,
17    pub platforms: Option<Vec<Platform>>,
18    pub medium: Option<Vec<ReleaseMedia>>,
19    /// List of visual novels this release is linked to
20    pub vns: Option<Vec<ReleaseVnRelation>>,
21    pub producers: Option<Vec<ReleaseProducer>>,
22    /// Release date
23    pub released: Option<String>,
24    /// Possibly null age rating
25    pub minage: Option<u8>,
26    pub patch: Option<bool>,
27    pub freeware: Option<bool>,
28    /// Can be null
29    pub uncensored: Option<bool>,
30    pub official: Option<bool>,
31    pub has_ero: Option<bool>,
32    /// Can be the string "non-standard" or an array of two integers indicating the width and height
33    pub resolution: Option<Resolution>,
34    pub engine: Option<String>,
35    /// Possibly null, 1 = not voiced, 2 = only ero scenes voiced, 3 = partially voiced, 4 = fully voiced
36    pub voiced: Option<VoicedType>,
37    /// May contain formatting codes
38    pub notes: Option<String>,
39    /// Possibly null JAN/EAN/UPC code
40    pub gtin: Option<String>,
41    pub catalog: Option<String>,
42    pub extlinks: Option<Vec<ExtLink>>,
43}
44
45#[derive(Deserialize, Serialize, Debug)]
46pub struct ReleaseLanguage {
47    /// Language
48    pub lang: Option<Language>,
49    /// Title in the original script can be null
50    /// in which case the title for this language is the same as the “main” language
51    pub title: Option<String>,
52    /// Can be null romanized version of title
53    pub latin: Option<String>,
54    /// Whether this is a machine translation
55    pub mtl: Option<bool>,
56    /// whether this language is used to determine the “main” title for the release entry
57    pub main: Option<bool>,
58}
59
60#[derive(Deserialize, Serialize, Debug)]
61pub struct ReleaseMedia {
62    pub medium: Option<Medium>,
63    /// Quantity. This is 0 for media where a quantity does not make sense, like “internet download”
64    pub qty: Option<u32>,
65}
66
67#[derive(Deserialize, Serialize, Debug)]
68pub struct ReleaseVnRelation {
69    /// The release type for this visual novel
70    pub rtype: Option<ReleaseType>,
71    /// Also implements all /vn fields
72    pub id: Option<String>,
73    pub title: Option<String>,
74    pub alttitle: Option<String>,
75    pub titles: Option<Vec<VnTitle>>,
76    pub aliases: Option<Vec<String>>,
77    pub olang: Option<Language>,
78    pub devstatus: Option<VnDevStatus>,
79    pub released: Option<String>,
80    pub languages: Option<Vec<Language>>,
81    pub platforms: Option<Vec<Platform>>,
82    pub image: Option<VnImage>,
83    pub length: Option<VnLength>,
84    pub length_minutes: Option<u32>,
85    pub length_votes: Option<u32>,
86    pub description: Option<String>,
87    pub rating: Option<f32>,
88    pub votecount: Option<u32>,
89    pub screenshots: Option<Vec<VnScreenShot>>,
90    pub relations: Option<Vec<VnRelation>>,
91    pub tags: Option<Vec<VnTag>>,
92    pub developers: Option<Vec<Producer>>,
93    pub editions: Option<Vec<VnEdition>>,
94    pub staff: Option<Vec<VnStaff>>,
95    pub va: Option<Vec<VnVoiceActor>>,
96    pub extlinks: Option<Vec<ExtLink>>,
97}
98
99#[derive(Deserialize, Serialize, Debug)]
100#[serde(rename_all = "lowercase")]
101pub enum ReleaseType {
102    Trial,
103    Partial,
104    Complete,
105}
106
107#[derive(Deserialize, Serialize, Debug)]
108pub struct ReleaseProducer {
109    pub developer: Option<bool>,
110    pub publisher: Option<bool>,
111    /// All /producer fields are also available
112    pub id: Option<String>,
113    pub name: Option<String>,
114    pub aliases: Option<Vec<String>>,
115    pub lang: Option<Language>,
116    pub r#type: Option<ProducerType>,
117    pub description: Option<String>,
118}
119
120#[derive(Deserialize, Serialize, Debug)]
121#[serde(untagged)]
122pub enum Resolution {
123    NonStandard(String),
124    Dimensions(Vec<u32>),
125}
126
127#[derive(Deserialize_repr, Serialize_repr, PartialEq, Debug)]
128#[repr(u8)]
129pub enum VoicedType {
130    NotVoiced = 1,
131    EroScenesOnly = 2,
132    PartiallyVoiced = 3,
133    FullyVoiced = 4,
134}
135
136#[derive(Deserialize, Serialize, Debug)]
137pub struct ExtLink {
138    /// External website URL
139    pub url: Option<String>,
140    /// English human-readable label for this link
141    pub label: Option<String>,
142    /// Internal identifier of the site
143    pub name: Option<String>,
144    /// Remote identifier for this link
145    pub id: Option<ExtLinkId>,
146}
147
148#[derive(Deserialize, Serialize, Debug)]
149#[serde(untagged)]
150pub enum ExtLinkId {
151    Str(String),
152    Int(u32),
153}