vndb_api/format/
vn.rs

1use crate::format::character::*;
2use crate::format::producer::Producer;
3use crate::format::release::*;
4use crate::format::schema::{Language, Platform, StaffRole};
5use crate::format::staff::*;
6use crate::format::tag::*;
7use serde::{Deserialize, Serialize};
8use serde_repr::*;
9
10#[derive(Deserialize, Serialize, Debug)]
11pub struct VisualNovel {
12    /// Vndbid
13    pub id: Option<String>,
14    pub title: Option<String>,
15    pub alttitle: Option<String>,
16    /// Full list of titles associated with the VN
17    pub titles: Option<Vec<VnTitle>>,
18    pub aliases: Option<Vec<String>>,
19    /// Language the VN has originally been written in
20    pub olang: Option<Language>,
21    pub devstatus: Option<VnDevStatus>,
22    /// Release date
23    pub released: Option<String>,
24    /// List of languages this VN is available in does not include machine translations
25    pub languages: Option<Vec<Language>>,
26    /// List of platforms for which this VN is available
27    pub platforms: Option<Vec<Platform>>,
28    pub image: Option<VnImage>,
29    /// Rough length estimate of the VN between very short and very long
30    pub length: Option<VnLength>,
31    /// Average of user-submitted play times in minutes
32    pub length_minutes: Option<u32>,
33    /// Number of submitted play times
34    pub length_votes: Option<u32>,
35    /// May contain formatting codes
36    pub description: Option<String>,
37    /// The rating of a VN from 10 to 100
38    pub rating: Option<f32>,
39    /// Number of votes
40    pub votecount: Option<u32>,
41    pub screenshots: Option<Vec<VnScreenShot>>,
42    /// List of VNs directly related to this entry
43    pub relations: Option<Vec<VnRelation>>,
44    /// VN tags
45    pub tags: Option<Vec<VnTag>>,
46    /// All producers with a “developer” role on a release linked to the VN
47    pub developers: Option<Vec<Producer>>,
48    /// List of VN editions
49    pub editions: Option<Vec<VnEdition>>,
50    /// List of staff members
51    pub staff: Option<Vec<VnStaff>>,
52    /// List of voice actors the same voice actor may be listed multiple times
53    /// for different characters and the same character may be listed multiple times
54    /// if it has been voiced by several people
55    pub va: Option<Vec<VnVoiceActor>>,
56    /// Links to external websites
57    pub extlinks: Option<Vec<ExtLink>>,
58}
59
60#[derive(Deserialize, Serialize, Debug)]
61pub struct VnTitle {
62    /// Language
63    pub lang: Option<Language>,
64    /// Title in the original script
65    pub title: Option<String>,
66    /// Romanized version of title
67    pub latin: Option<String>,
68    /// Whether this title is the official title of the VN
69    pub official: Option<bool>,
70    /// Whether this is the "main" title for the VN entry
71    pub main: Option<bool>,
72}
73
74#[derive(Deserialize_repr, Serialize_repr, PartialEq, Debug)]
75#[repr(u8)]
76pub enum VnDevStatus {
77    Finished = 0,
78    InDevelopment = 1,
79    Cancelled = 2,
80}
81
82#[derive(Deserialize, Serialize, Debug)]
83pub struct VnImage {
84    pub id: Option<String>,
85    pub url: Option<String>,
86    /// Pixel dimensions of the image [width, height]
87    pub dims: Option<Vec<u32>>,
88    /// Average image flagging vote for sexual content between 0 and 2 (inclusive)
89    pub sexual: Option<f32>,
90    /// Average image flagging vote for violence between 0 and 2 (inclusive)
91    pub violence: Option<f32>,
92    /// Number of image flagging votes
93    pub votecount: Option<u32>,
94    /// URL to the thumbnail
95    pub thumbnail: Option<String>,
96    /// Pixel dimensions of the thumbnail [width, height]
97    pub thumbnail_dims: Option<Vec<u32>>,
98}
99
100#[derive(Deserialize_repr, Serialize_repr, PartialEq, Debug)]
101#[repr(u8)]
102pub enum VnLength {
103    VeryShort = 1,
104    Short = 2,
105    Average = 3,
106    Long = 4,
107    VeryLong = 5,
108}
109
110#[derive(Deserialize, Serialize, Debug)]
111pub struct VnScreenShot {
112    /// Image fields also apply to screenshots
113    pub id: Option<String>,
114    pub url: Option<String>,
115    pub dims: Option<Vec<u32>>,
116    pub sexual: Option<f32>,
117    pub violence: Option<f32>,
118    pub votecount: Option<u32>,
119    pub thumbnail: Option<String>,
120    pub thumbnail_dims: Option<Vec<u32>>,
121    // Includes a release object
122    pub release: Option<Release>,
123}
124
125#[derive(Deserialize, Serialize, Debug)]
126pub struct VnRelation {
127    /// Relation type
128    pub relation: Option<String>,
129    pub relation_official: Option<bool>,
130    /// all visual novel fields need to be selected here
131    pub id: Option<String>,
132    pub title: Option<String>,
133    pub alttitle: Option<String>,
134    pub titles: Option<Vec<VnTitle>>,
135    pub aliases: Option<Vec<String>>,
136    pub olang: Option<Language>,
137    pub devstatus: Option<VnDevStatus>,
138    pub released: Option<String>,
139    pub languages: Option<Vec<Language>>,
140    pub platforms: Option<Vec<Platform>>,
141    pub image: Option<VnImage>,
142    pub length: Option<VnLength>,
143    pub length_minutes: Option<u32>,
144    pub length_votes: Option<u32>,
145    pub description: Option<String>,
146    pub rating: Option<f32>,
147    pub votecount: Option<u32>,
148    pub screenshots: Option<Vec<VnScreenShot>>,
149    pub relations: Option<Vec<VnRelation>>,
150    pub tags: Option<Vec<VnTag>>,
151    pub developers: Option<Vec<Producer>>,
152    pub editions: Option<Vec<VnEdition>>,
153    pub staff: Option<Vec<VnStaff>>,
154    pub va: Option<Vec<VnVoiceActor>>,
155    pub extlinks: Option<Vec<ExtLink>>,
156}
157
158#[derive(Deserialize, Serialize, Debug)]
159pub struct VnTag {
160    /// Tag rating between 0 (exclusive) and 3 (inclusive)
161    pub rating: Option<f32>,
162    /// Spoiler level
163    pub spoiler: Option<TagSpoilerLvl>,
164    pub lie: Option<bool>,
165    /// Also takes all /tag fields
166    pub id: Option<String>,
167    pub name: Option<String>,
168    pub aliases: Option<Vec<String>>,
169    pub description: Option<String>,
170    pub category: Option<TagFlag>,
171    pub searchable: Option<bool>,
172    pub vn_count: Option<u32>,
173}
174
175#[derive(Deserialize, Serialize, Debug)]
176pub struct VnEdition {
177    /// Edition identifier local to the visual novel
178    /// Not stable across edits of the VN entry
179    /// Only used for organizing the staff listing
180    pub eid: Option<u16>,
181    pub lang: Option<Language>,
182    /// English name / label identifying this edition
183    pub name: Option<String>,
184    /// Whether this edition is official
185    pub official: Option<bool>,
186}
187
188#[derive(Deserialize, Serialize, Debug)]
189pub struct VnStaff {
190    /// Edition identifier when the staff has worked on the “original” version of the VN
191    pub eid: Option<u32>,
192    /// Staff member's role
193    pub role: Option<StaffRole>,
194    pub note: Option<String>,
195    /// Also implements all /staff fields
196    pub id: Option<String>,
197    pub aid: Option<u32>,
198    pub ismain: Option<bool>,
199    pub name: Option<String>,
200    pub original: Option<String>,
201    pub lang: Option<Language>,
202    pub gender: Option<StaffGender>,
203    pub description: Option<String>,
204    pub extlinks: Option<Vec<ExtLink>>,
205    pub aliases: Option<Vec<StaffAlias>>,
206}
207
208#[derive(Deserialize, Serialize, Debug)]
209pub struct VnVoiceActor {
210    pub note: Option<String>,
211    pub staff: Option<Staff>,
212    pub character: Option<Character>,
213}