1use std::str::FromStr;
2
3#[derive(Clone, Debug, Copy)]
4pub enum StringNetworkType {
5 Physical,
7
8 Functional,
10}
11impl std::fmt::Display for StringNetworkType {
12 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
13 match self {
14 Self::Physical => write!(f, "physical"),
15 Self::Functional => write!(f, "functional"),
16 }
17 }
18}
19impl FromStr for StringNetworkType {
20 type Err = String;
21
22 fn from_str(s: &str) -> Result<Self, Self::Err> {
23 match s.to_lowercase().as_str() {
24 "physical" => Ok(Self::Physical),
25 "functional" => Ok(Self::Functional),
26 _ => Err(format!("Invalid network type: {}", s)),
27 }
28 }
29}