tembo_api_client/models/
cpu.rs

1/*
2 * Tembo Cloud
3 *
4 * Platform API for Tembo Cloud             </br>             </br>             To find a Tembo Data API, please find it here:             </br>             </br>             [AWS US East 1](https://api.data-1.use1.tembo.io/swagger-ui/)
5 *
6 * The version of the OpenAPI document: v1.0.0
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use serde::{Deserialize, Serialize};
12
13///
14#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
15pub enum Cpu {
16    #[serde(rename = "0.25")]
17    Variant0Period25,
18    #[serde(rename = "0.5")]
19    Variant0Period5,
20    #[serde(rename = "1")]
21    Variant1,
22    #[serde(rename = "2")]
23    Variant2,
24    #[serde(rename = "4")]
25    Variant4,
26    #[serde(rename = "6")]
27    Variant6,
28    #[serde(rename = "8")]
29    Variant8,
30    #[serde(rename = "12")]
31    Variant12,
32    #[serde(rename = "16")]
33    Variant16,
34    #[serde(rename = "32")]
35    Variant32,
36}
37
38impl std::fmt::Display for Cpu {
39    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
40        match self {
41            Self::Variant0Period25 => write!(f, "0.25"),
42            Self::Variant0Period5 => write!(f, "0.5"),
43            Self::Variant1 => write!(f, "1"),
44            Self::Variant2 => write!(f, "2"),
45            Self::Variant4 => write!(f, "4"),
46            Self::Variant6 => write!(f, "6"),
47            Self::Variant8 => write!(f, "8"),
48            Self::Variant12 => write!(f, "12"),
49            Self::Variant16 => write!(f, "16"),
50            Self::Variant32 => write!(f, "32"),
51        }
52    }
53}
54
55impl Default for Cpu {
56    fn default() -> Cpu {
57        Self::Variant0Period25
58    }
59}
60
61impl std::str::FromStr for Cpu {
62    type Err = String;
63
64    fn from_str(s: &str) -> Result<Self, Self::Err> {
65        match s {
66            "0.25" => Ok(Self::Variant0Period25),
67            "0.5" => Ok(Self::Variant0Period5),
68            "1" => Ok(Self::Variant1),
69            "2" => Ok(Self::Variant2),
70            "4" => Ok(Self::Variant4),
71            "6" => Ok(Self::Variant6),
72            "8" => Ok(Self::Variant8),
73            "12" => Ok(Self::Variant12),
74            "16" => Ok(Self::Variant16),
75            "32" => Ok(Self::Variant32),
76            _ => Err(format!("Invalid CPU value: {}", s)),
77        }
78    }
79}