nimbuspulse_client/types/
instance.rs1use serde::{Deserialize, Serialize};
2use uuid::Uuid;
3
4use super::dcs_settings::DcsSettings;
5
6#[derive(Debug, Deserialize, Clone)]
7#[cfg_attr(test, derive(ts_rs::TS))]
8#[cfg_attr(test, ts(export, export_to = "../../javascript/lib/types/"))]
9pub struct Instance {
10 pub id: Uuid,
11 pub node_id: Uuid,
12 pub user_id: String,
13 pub product_id: Uuid,
14 pub ip: String,
15 pub port: u32,
16 pub webgui_port: u32,
17 pub ftp_port: u32,
18 pub ftp_username: String,
19 pub ftp_password: String,
20 pub pid: Option<u32>,
21 pub status: InstanceStatus,
22 pub want_delete: bool,
23 pub wanted_terrains: Vec<Terrain>,
24 pub rented_at: u64,
25 pub rented_until: Option<u32>,
26 pub active_mods: Vec<String>,
27 pub created_at: String,
28 pub dcs_settings: Option<DcsSettings>,
29}
30
31#[derive(Debug, Serialize, Deserialize, Clone)]
32#[cfg_attr(test, derive(ts_rs::TS))]
33#[cfg_attr(test, ts(export, export_to = "../../javascript/lib/types/"))]
34pub enum Terrain {
35 Afghanistan,
36 Caucasus,
37 Falklands,
38 Iraq,
39 Kola,
40 MarianaIslands,
41 Nevada,
42 Normandy,
43 PersianGulf,
44 Sinai,
45 Syria,
46 TheChannel,
47 GermanyCW,
48}
49
50#[derive(Debug, Deserialize, Clone)]
51#[cfg_attr(test, derive(ts_rs::TS))]
52#[cfg_attr(test, ts(export, export_to = "../../javascript/lib/types/"))]
53pub enum InstanceStatus {
54 InstallingBaseGame {
55 progress: Option<u8>,
56 },
57 InstallingTerrains {
58 installed: Vec<Terrain>,
59 processing: Option<Terrain>,
60 processing_progress: Option<u8>,
61 },
62 InstallingMods,
63 InstallingPost,
64 ServerStarted,
65 ServerStopped {
66 was_error: bool,
67 reason: InstanceStoppedReason,
68 },
69 ServerExpired,
70 ServerDeleted,
71 WantServerStarted {
72 current_try: u32,
73 },
74 WantServerStopped {
75 error_passthrough: Option<(bool, InstanceStoppedReason)>,
76 },
77 WantUpdateServer,
78}
79
80#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
81#[cfg_attr(test, derive(ts_rs::TS))]
82#[cfg_attr(test, ts(export, export_to = "../../javascript/lib/types/"))]
83pub enum InstanceStoppedReason {
84 StoppedNormally,
85 StoppedUnexpectedly,
86 MaxTriesReached,
87 ServerUpdating,
88}