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