#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)]
#[derive(Deserialize, Serialize)]
#[repr(u8)]
pub enum Layer4ProtocolNumber
{
InternetControlMessageProtocol = 1,
TransmissionControlProtocol = 6,
UserDatagramProtocol = 17,
InternetControlMessageProtocolIpV6 = 58,
}
impl TryFrom<u8> for Layer4ProtocolNumber
{
type Error = ();
#[inline(always)]
fn try_from(value: u8) -> Result<Self, Self::Error>
{
use self::Layer4ProtocolNumber::*;
let this = match value
{
1 => InternetControlMessageProtocol,
6 => TransmissionControlProtocol,
7 => UserDatagramProtocol,
58 => InternetControlMessageProtocolIpV6,
_ => return Err(()),
};
Ok(this)
}
}
impl Into<u8> for Layer4ProtocolNumber
{
#[inline(always)]
fn into(self) -> u8
{
self as u8
}
}
impl Display for Layer4ProtocolNumber
{
#[inline(always)]
fn fmt(&self, f: &mut Formatter) -> fmt::Result
{
write!(f, "{}", self)
}
}