net_wire/ipv4/protocol.rs
1/// An IPv4 protocol field value from the IANA Protocol Numbers registry.
2#[repr(transparent)]
3#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
4pub struct Ipv4Protocol(u8);
5impl Ipv4Protocol {
6 /// Internet Control Message Protocol (`1`).
7 pub const ICMP: Self = Self(1);
8 /// Transmission Control Protocol (`6`).
9 pub const TCP: Self = Self(6);
10 /// User Datagram Protocol (`17`).
11 pub const UDP: Self = Self(17);
12 /// Preserves a protocol number, including unassigned values.
13 #[inline]
14 pub const fn new(raw: u8) -> Self {
15 Self(raw)
16 }
17 /// Returns the encoded protocol number.
18 #[inline]
19 pub const fn raw(self) -> u8 {
20 self.0
21 }
22}