network/fundamentals/
port.rs

1#[repr(transparent)]
2#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
3pub struct Port(u16);
4
5impl Port {
6    pub const MINIMUM_USER: Self = Self(1025);
7    pub const MAXIMUM: Self = Self(u16::MAX);
8
9    pub const DHCP_SERVER: Self = Self(67);
10    pub const DHCP_CLIENT: Self = Self(68);
11
12    pub const fn new(value: u16) -> Self {
13        Self(value)
14    }
15
16    pub const fn into_inner(self) -> u16 {
17        self.0
18    }
19
20    pub const fn from_inner(value: u16) -> Self {
21        Self(value)
22    }
23}
24
25impl From<u16> for Port {
26    fn from(value: u16) -> Self {
27        Self::new(value)
28    }
29}
30
31impl From<Port> for u16 {
32    fn from(value: Port) -> Self {
33        value.into_inner()
34    }
35}