tembo_api_client/models/
cpu.rs1use serde::{Deserialize, Serialize};
12
13#[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}