renet/src/wire/ip.rs

22 lines
535 B
Rust
Raw Normal View History

2016-12-13 01:26:06 +08:00
use core::fmt;
enum_with_unknown! {
/// Internet protocol type.
pub enum ProtocolType(u8) {
Icmp = 0x01,
Tcp = 0x06,
Udp = 0x11
}
}
impl fmt::Display for ProtocolType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
&ProtocolType::Icmp => write!(f, "ICMP"),
&ProtocolType::Tcp => write!(f, "TCP"),
&ProtocolType::Udp => write!(f, "UDP"),
&ProtocolType::Unknown(id) => write!(f, "0x{:02x}", id)
}
}
}