1#[cfg(test)]
2mod tcp_type_test;
3
4use std::fmt;
5
6#[derive(Default, PartialEq, Eq, Debug, Copy, Clone)]
9pub enum TcpType {
10 #[default]
12 Unspecified,
13 Active,
15 Passive,
17 SimultaneousOpen,
19}
20
21impl From<&str> for TcpType {
23 fn from(raw: &str) -> Self {
24 match raw {
25 "active" => Self::Active,
26 "passive" => Self::Passive,
27 "so" => Self::SimultaneousOpen,
28 _ => Self::Unspecified,
29 }
30 }
31}
32
33impl fmt::Display for TcpType {
34 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
35 let s = match *self {
36 Self::Active => "active",
37 Self::Passive => "passive",
38 Self::SimultaneousOpen => "so",
39 Self::Unspecified => "unspecified",
40 };
41 write!(f, "{s}")
42 }
43}