Skip to main content

holodeck_simctl_core/models/
simulator_state.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
4pub enum SimulatorState {
5    #[serde(rename = "Booted")]
6    Booted,
7    #[serde(rename = "Shutdown")]
8    Shutdown,
9    #[serde(rename = "Booting")]
10    Booting,
11    #[serde(rename = "Shutting Down")]
12    ShuttingDown,
13    #[serde(rename = "Creating")]
14    Creating,
15}
16
17impl SimulatorState {
18    pub fn raw_value(self) -> &'static str {
19        match self {
20            SimulatorState::Booted => "Booted",
21            SimulatorState::Shutdown => "Shutdown",
22            SimulatorState::Booting => "Booting",
23            SimulatorState::ShuttingDown => "Shutting Down",
24            SimulatorState::Creating => "Creating",
25        }
26    }
27
28    pub fn from_raw_value(raw: &str) -> Option<Self> {
29        match raw {
30            "Booted" => Some(SimulatorState::Booted),
31            "Shutdown" => Some(SimulatorState::Shutdown),
32            "Booting" => Some(SimulatorState::Booting),
33            "Shutting Down" => Some(SimulatorState::ShuttingDown),
34            "Creating" => Some(SimulatorState::Creating),
35            _ => None,
36        }
37    }
38}