diff --git a/src/ice/candidate.rs b/src/ice/candidate.rs index 0183abe9..fc194aea 100644 --- a/src/ice/candidate.rs +++ b/src/ice/candidate.rs @@ -446,39 +446,6 @@ impl fmt::Display for CandidateKind { } } -impl TryFrom<&str> for Protocol { - type Error = (); - - fn try_from(proto: &str) -> Result { - let proto = proto.to_lowercase(); - match proto.as_str() { - "udp" => Ok(Protocol::Udp), - "tcp" => Ok(Protocol::Tcp), - "ssltcp" => Ok(Protocol::SslTcp), - "tls" => Ok(Protocol::Tls), - _ => Err(()), - } - } -} - -impl From for &str { - fn from(proto: Protocol) -> Self { - match proto { - Protocol::Udp => "udp", - Protocol::Tcp => "tcp", - Protocol::SslTcp => "ssltcp", - Protocol::Tls => "tls", - } - } -} - -impl fmt::Display for Protocol { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let x: &str = (*self).into(); - write!(f, "{}", x) - } -} - fn is_valid_ip(ip: IpAddr) -> bool { match ip { IpAddr::V4(v) => { diff --git a/src/io/mod.rs b/src/io/mod.rs index 208f8463..47e7d4cb 100644 --- a/src/io/mod.rs +++ b/src/io/mod.rs @@ -243,3 +243,36 @@ impl fmt::Debug for DatagramRecv<'_> { } // } + +impl TryFrom<&str> for Protocol { + type Error = (); + + fn try_from(proto: &str) -> Result { + let proto = proto.to_lowercase(); + match proto.as_str() { + "udp" => Ok(Protocol::Udp), + "tcp" => Ok(Protocol::Tcp), + "ssltcp" => Ok(Protocol::SslTcp), + "tls" => Ok(Protocol::Tls), + _ => Err(()), + } + } +} + +impl From for &str { + fn from(proto: Protocol) -> Self { + match proto { + Protocol::Udp => "udp", + Protocol::Tcp => "tcp", + Protocol::SslTcp => "ssltcp", + Protocol::Tls => "tls", + } + } +} + +impl fmt::Display for Protocol { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let x: &str = (*self).into(); + write!(f, "{}", x) + } +}