nimbuspulse_client/types/
instance.rs

1use 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}
48
49#[derive(Debug, Deserialize, Clone)]
50#[cfg_attr(test, derive(ts_rs::TS))]
51#[cfg_attr(test, ts(export, export_to = "../../javascript/lib/types/"))]
52pub enum InstanceStatus {
53    InstallingBaseGame {
54        progress: Option<u8>,
55    },
56    InstallingTerrains {
57        installed: Vec<Terrain>,
58        processing: Option<Terrain>,
59        processing_progress: Option<u8>,
60    },
61    InstallingMods,
62    InstallingPost,
63    ServerStarted,
64    ServerStopped {
65        was_error: bool,
66        reason: InstanceStoppedReason,
67    },
68    ServerExpired,
69    ServerDeleted,
70    WantServerStarted {
71        current_try: u32,
72    },
73    WantServerStopped {
74        error_passthrough: Option<(bool, InstanceStoppedReason)>,
75    },
76    WantUpdateServer,
77}
78
79#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
80#[cfg_attr(test, derive(ts_rs::TS))]
81#[cfg_attr(test, ts(export, export_to = "../../javascript/lib/types/"))]
82pub enum InstanceStoppedReason {
83    StoppedNormally,
84    StoppedUnexpectedly,
85    MaxTriesReached,
86}