ic_query/subnet_catalog/model/classification/
geographic.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 GeographicScope {
17 Global,
19 Europe,
21 Unknown,
23}
24
25impl GeographicScope {
26 #[must_use]
28 pub const fn as_str(self) -> &'static str {
29 match self {
30 Self::Global => "global",
31 Self::Europe => "europe",
32 Self::Unknown => "unknown",
33 }
34 }
35}
36
37impl FromStr for GeographicScope {
38 type Err = String;
39
40 fn from_str(value: &str) -> Result<Self, Self::Err> {
41 match value {
42 "global" => Ok(Self::Global),
43 "europe" => Ok(Self::Europe),
44 "unknown" => Ok(Self::Unknown),
45 other => Err(format!(
46 "invalid value {other}; use global, europe, or unknown"
47 )),
48 }
49 }
50}