tembo_api_client/models/
cpu.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
 * Tembo Cloud
 *
 * 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/)
 *
 * The version of the OpenAPI document: v1.0.0
 *
 * Generated by: https://openapi-generator.tech
 */

use 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)),
        }
    }
}