ic_query/subnet_catalog/model/classification/
kind.rs1use serde::{Deserialize, Serialize};
6use std::str::FromStr;
7
8#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
15#[serde(rename_all = "snake_case")]
16pub enum SubnetKind {
17 Application,
19 CloudEngine,
21 System,
23 Unknown,
25}
26
27impl SubnetKind {
28 #[must_use]
30 pub const fn as_str(self) -> &'static str {
31 match self {
32 Self::Application => "application",
33 Self::CloudEngine => "cloud_engine",
34 Self::System => "system",
35 Self::Unknown => "unknown",
36 }
37 }
38
39 #[must_use]
41 pub const fn charges_apply_by_default(self) -> bool {
42 matches!(self, Self::Application | Self::CloudEngine)
43 }
44}
45
46impl FromStr for SubnetKind {
47 type Err = String;
48
49 fn from_str(value: &str) -> Result<Self, Self::Err> {
50 match value {
51 "application" => Ok(Self::Application),
52 "cloud_engine" => Ok(Self::CloudEngine),
53 "system" => Ok(Self::System),
54 "unknown" => Ok(Self::Unknown),
55 other => Err(format!(
56 "invalid value {other}; use application, cloud_engine, system, or unknown"
57 )),
58 }
59 }
60}