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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
#![allow(non_snake_case)]
use serde_json::value::Map;
use serde_json::Value;
#[derive(Serialize, Deserialize, Debug)]
pub struct BStart {
pub secret: String,
pub http: Map<String, Value>,
pub https: Map<String, Value>,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Game {
pub id: i32,
pub url: String,
pub title: String,
pub short_text: String,
pub cover_url: String,
#[serde(default)]
pub still_cover_url: String,
#[serde(flatten)]
pub dates: Dates,
#[serde(default)]
pub min_price: i32,
pub can_be_bought: bool,
#[serde(default)]
pub has_demo: bool,
#[serde(default)]
pub in_press_system: bool,
pub user: Option<User>,
pub sale: Option<Sale>,
pub user_id: Option<i32>,
pub views_count: Option<i32>,
pub downloads_count: Option<i32>,
pub purchases_count: Option<i32>,
pub published: Option<bool>,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct ProfileGame {
pub game: Game,
pub views_count: i32,
pub downloads_count: i32,
pub purchases_count: i32,
pub published: bool,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Profile {
pub id: i32,
pub last_connected: String,
pub user: User,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Upload {
pub id: i32,
pub storage: String,
#[serde(default)]
pub host: String,
pub filename: String,
pub display_name: String,
pub size: i32,
#[serde(default)]
pub channel_name: String,
#[serde(default)]
pub build_id: i32,
pub preorder: bool,
pub demo: bool,
#[serde(flatten)]
pub dates: Dates,
pub platforms: Platforms,
}
impl Upload {
pub fn supports(&self, os: &str) -> bool {
match os {
"windows" => self.platforms.windows.is_some(),
"osx" => self.platforms.osx.is_some(),
"linux" => self.platforms.linux.is_some(),
_ => false,
}
}
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub enum Archs {
All,
#[serde(rename = "386")]
i386,
Amd64,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct Platforms {
windows: Option<Archs>,
osx: Option<Archs>,
linux: Option<Archs>,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct User {
pub id: i32,
pub username: String,
pub display_name: String,
pub developer: bool,
pub press_user: bool,
pub url: String,
pub cover_url: String,
#[serde(default)]
pub still_cover_url: String,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Build {
pub id: i32,
pub parent_build_id: i32,
pub state: String,
pub version: i32,
#[serde(default)]
pub user_version: String,
pub user: Option<User>,
#[serde(flatten)]
pub dates: Dates,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct Cave {
pub id: String,
pub game: Game,
pub upload: Upload,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct Response {
pub id: i32,
pub jsonrpc: String,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Dates {
#[serde(default)]
pub created_at: String,
#[serde(default)]
pub updated_at: String,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct ResponseErr {
#[serde(flatten)]
pub response: Response,
pub error: BError,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct ResponseRes {
#[serde(flatten)]
pub response: Response,
pub result: Map<String, Value>,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Sale {
pub id: i32,
pub game_id: i32,
pub rate: i32,
pub start_date: String,
pub end_date: String,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct InstallLocationSummary {
pub id: String,
pub path: String,
pub size_info: InstallLocationSizeInfo,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct InstallLocationSizeInfo {
pub installed_size: i64,
pub free_size: i64,
pub total_size: i64,
}
#[derive(Serialize, Deserialize, Debug)]
pub enum DownloadReason {
#[serde(rename = "install")]
Install,
#[serde(rename = "reinstall")]
Reinstall,
#[serde(rename = "update")]
Update,
#[serde(rename = "version-switch")]
VersionSwitch,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct QueueResponse {
pub id: String,
pub reason: DownloadReason,
pub cave_id: String,
pub game: Game,
pub upload: Upload,
pub build: Build,
pub install_folder: String,
pub staging_folder: String,
pub install_location_id: String,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct InstallQueueReq {
pub install_location_id: String,
pub reason: String,
pub game: Game,
pub upload: Upload,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Download {
pub id: String,
pub error: Option<String>,
pub error_message: Option<String>,
pub error_code: Option<String>,
pub reason: DownloadReason,
pub position: i32,
pub cave_id: String,
pub game: Game,
pub upload: Upload,
pub build: Option<Build>,
pub started_at: String,
pub finished_at: Option<String>,
pub staging_folder: String,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct VersionInfo {
pub version: String,
pub version_string: String,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct CheckUpdate {
pub updates: Option<Vec<GameUpdate>>,
pub warnings: Option<Vec<String>>,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct GameUpdate {
pub cave_id: String,
pub game: Game,
pub direct: bool,
pub choices: Option<Vec<GameUpdateChoice>>,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct GameUpdateChoice {
pub upload: Upload,
pub build: Option<Build>,
pub confidence: f64,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct PassLogRes {
pub profile: Profile,
pub cookie: Map<String, Value>,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct DownloadKey {
pub id: i64,
pub game_id: i32,
pub game: Game,
pub owner_id: i64,
#[serde(flatten)]
pub dates: Dates,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Commons {
pub download_keys: Vec<DownloadKeySummary>,
pub caves: Vec<CaveSummary>,
pub install_locations: Vec<InstallLocationSummary>,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct DownloadKeySummary {
pub id: i64,
pub game_id: i32,
pub created_at: String,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct CaveSummary {
pub id: String,
pub game_id: i32,
pub last_touched_at: Option<String>,
pub seconds_run: i32,
pub installed_size: i64,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Collection {
pub id: i32,
pub title: String,
#[serde(flatten)]
pub dates: Dates,
pub games_count: i32,
pub collection_games: Option<Vec<CollectionGame>>,
pub user_id: i32,
pub user: User,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct CollectionGame {
pub collection_id: i32,
pub collection: Collection,
pub game_id: i32,
pub game: Game,
pub position: i32,
pub blurb: String,
pub user_id: i32,
#[serde(flatten)]
pub dates: Dates,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct FsInfo {
pub free_size: i64,
pub total_size: i64,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct CleanDownloadsEntry {
pub path: String,
pub size: i64,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct BError {
pub code: i64,
pub message: String,
}