tembo_api_client/models/
cpu.rsuse crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Cpu {
#[serde(rename = "0.25")]
Variant0Period25,
#[serde(rename = "0.5")]
Variant0Period5,
#[serde(rename = "1")]
Variant1,
#[serde(rename = "2")]
Variant2,
#[serde(rename = "4")]
Variant4,
#[serde(rename = "6")]
Variant6,
#[serde(rename = "8")]
Variant8,
#[serde(rename = "12")]
Variant12,
#[serde(rename = "16")]
Variant16,
#[serde(rename = "32")]
Variant32,
}
impl std::fmt::Display for Cpu {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Self::Variant0Period25 => write!(f, "0.25"),
Self::Variant0Period5 => write!(f, "0.5"),
Self::Variant1 => write!(f, "1"),
Self::Variant2 => write!(f, "2"),
Self::Variant4 => write!(f, "4"),
Self::Variant6 => write!(f, "6"),
Self::Variant8 => write!(f, "8"),
Self::Variant12 => write!(f, "12"),
Self::Variant16 => write!(f, "16"),
Self::Variant32 => write!(f, "32"),
}
}
}
impl Default for Cpu {
fn default() -> Cpu {
Self::Variant0Period25
}
}
impl std::str::FromStr for Cpu {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"0.25" => Ok(Self::Variant0Period25),
"0.5" => Ok(Self::Variant0Period5),
"1" => Ok(Self::Variant1),
"2" => Ok(Self::Variant2),
"4" => Ok(Self::Variant4),
"6" => Ok(Self::Variant6),
"8" => Ok(Self::Variant8),
"12" => Ok(Self::Variant12),
"16" => Ok(Self::Variant16),
"32" => Ok(Self::Variant32),
_ => Err(format!("Invalid CPU value: {}", s)),
}
}
}