toe_beans/v4/message/
htype.rs

1/// Variants of a htype field in [Message](crate::v4::Message).
2///
3/// See the full [IANA list](https://www.iana.org/assignments/arp-parameters/arp-parameters.xhtml#arp-parameters-2).
4#[derive(Debug, PartialEq)]
5#[repr(u8)]
6pub enum HTypes {
7    /// 1
8    Ethernet,
9    /// 2
10    ExperimentalEthernet,
11    /// 3
12    AmateurRadio,
13    /// 4
14    ProteonTokenRing,
15    /// 5
16    Chaos,
17    /// 6
18    IEEE802,
19    /// 7
20    ARCNET,
21    /// 8
22    Hyperchannel,
23    /// 9
24    Lanstar,
25    /// 10
26    AutonetShortAddress,
27    /// 11
28    LocalTalk,
29    /// 12
30    LocalNet,
31    /// 13
32    UltraLink,
33    /// 14
34    SMDS,
35    /// 15
36    FrameRelay,
37    /// 16
38    ATM16,
39    /// 17
40    HDLC,
41    /// 18
42    FibreChannel,
43    /// 19
44    ATM19,
45    /// 20
46    SerialLine,
47    /// 21
48    ATM21,
49    /// 22
50    MILSTD188220,
51    /// 23
52    Metricom,
53    /// 24
54    IEEE13941995,
55    /// 25
56    MAPOS,
57    /// 26
58    Twinaxial,
59    /// 27
60    EUI64,
61    /// 28
62    HIPARP,
63    /// 29
64    IPARPISO78163,
65    /// 30
66    ARPSec,
67    /// 31
68    IPsecTunnel,
69    /// 32
70    InfiniBand,
71    /// 33
72    CommonAirInterface,
73    /// 34
74    WiegandInterface,
75    /// 35
76    PureIP,
77    /// 36
78    HWEXP1,
79    /// 37
80    HFI,
81    /// 38
82    UnifiedBus,
83    /// 0 is Reserved
84    /// 39-255 are Unassigned
85    Other(u8),
86}
87
88// Encode
89impl From<&HTypes> for u8 {
90    fn from(htypes: &HTypes) -> Self {
91        match htypes {
92            HTypes::Ethernet => 1,
93            HTypes::ExperimentalEthernet => 2,
94            HTypes::AmateurRadio => 3,
95            HTypes::ProteonTokenRing => 4,
96            HTypes::Chaos => 5,
97            HTypes::IEEE802 => 6,
98            HTypes::ARCNET => 7,
99            HTypes::Hyperchannel => 8,
100            HTypes::Lanstar => 9,
101            HTypes::AutonetShortAddress => 10,
102            HTypes::LocalTalk => 11,
103            HTypes::LocalNet => 12,
104            HTypes::UltraLink => 13,
105            HTypes::SMDS => 14,
106            HTypes::FrameRelay => 15,
107            HTypes::ATM16 => 16,
108            HTypes::HDLC => 17,
109            HTypes::FibreChannel => 18,
110            HTypes::ATM19 => 19,
111            HTypes::SerialLine => 20,
112            HTypes::ATM21 => 21,
113            HTypes::MILSTD188220 => 22,
114            HTypes::Metricom => 23,
115            HTypes::IEEE13941995 => 24,
116            HTypes::MAPOS => 25,
117            HTypes::Twinaxial => 26,
118            HTypes::EUI64 => 27,
119            HTypes::HIPARP => 28,
120            HTypes::IPARPISO78163 => 29,
121            HTypes::ARPSec => 30,
122            HTypes::IPsecTunnel => 31,
123            HTypes::InfiniBand => 32,
124            HTypes::CommonAirInterface => 33,
125            HTypes::WiegandInterface => 34,
126            HTypes::PureIP => 35,
127            HTypes::HWEXP1 => 36,
128            HTypes::HFI => 37,
129            HTypes::UnifiedBus => 38,
130            HTypes::Other(x) => *x,
131        }
132    }
133}
134
135// Decode
136impl From<u8> for HTypes {
137    fn from(byte: u8) -> Self {
138        match byte {
139            1 => Self::Ethernet,
140            2 => Self::ExperimentalEthernet,
141            3 => Self::AmateurRadio,
142            4 => Self::ProteonTokenRing,
143            5 => Self::Chaos,
144            6 => Self::IEEE802,
145            7 => Self::ARCNET,
146            8 => Self::Hyperchannel,
147            9 => Self::Lanstar,
148            10 => Self::AutonetShortAddress,
149            11 => Self::LocalTalk,
150            12 => Self::LocalNet,
151            13 => Self::UltraLink,
152            14 => Self::SMDS,
153            15 => Self::FrameRelay,
154            16 => Self::ATM16,
155            17 => Self::HDLC,
156            18 => Self::FibreChannel,
157            19 => Self::ATM19,
158            20 => Self::SerialLine,
159            21 => Self::ATM21,
160            22 => Self::MILSTD188220,
161            23 => Self::Metricom,
162            24 => Self::IEEE13941995,
163            25 => Self::MAPOS,
164            26 => Self::Twinaxial,
165            27 => Self::EUI64,
166            28 => Self::HIPARP,
167            29 => Self::IPARPISO78163,
168            30 => Self::ARPSec,
169            31 => Self::IPsecTunnel,
170            32 => Self::InfiniBand,
171            33 => Self::CommonAirInterface,
172            34 => Self::WiegandInterface,
173            35 => Self::PureIP,
174            36 => Self::HWEXP1,
175            37 => Self::HFI,
176            38 => Self::UnifiedBus,
177            _ => Self::Other(byte),
178        }
179    }
180}