toe-beans 0.10.0

DHCP library, client, and server
Documentation
/// Variants of a htype field in [Message](crate::v4::Message).
///
/// See the full [IANA list](https://www.iana.org/assignments/arp-parameters/arp-parameters.xhtml#arp-parameters-2).
#[derive(Debug, PartialEq)]
#[repr(u8)]
pub enum HTypes {
    /// 1
    Ethernet,
    /// 2
    ExperimentalEthernet,
    /// 3
    AmateurRadio,
    /// 4
    ProteonTokenRing,
    /// 5
    Chaos,
    /// 6
    IEEE802,
    /// 7
    ARCNET,
    /// 8
    Hyperchannel,
    /// 9
    Lanstar,
    /// 10
    AutonetShortAddress,
    /// 11
    LocalTalk,
    /// 12
    LocalNet,
    /// 13
    UltraLink,
    /// 14
    SMDS,
    /// 15
    FrameRelay,
    /// 16
    ATM16,
    /// 17
    HDLC,
    /// 18
    FibreChannel,
    /// 19
    ATM19,
    /// 20
    SerialLine,
    /// 21
    ATM21,
    /// 22
    MILSTD188220,
    /// 23
    Metricom,
    /// 24
    IEEE13941995,
    /// 25
    MAPOS,
    /// 26
    Twinaxial,
    /// 27
    EUI64,
    /// 28
    HIPARP,
    /// 29
    IPARPISO78163,
    /// 30
    ARPSec,
    /// 31
    IPsecTunnel,
    /// 32
    InfiniBand,
    /// 33
    CommonAirInterface,
    /// 34
    WiegandInterface,
    /// 35
    PureIP,
    /// 36
    HWEXP1,
    /// 37
    HFI,
    /// 38
    UnifiedBus,
    /// 0 is Reserved
    /// 39-255 are Unassigned
    Other(u8),
}

// Encode
impl From<&HTypes> for u8 {
    fn from(htypes: &HTypes) -> Self {
        match htypes {
            HTypes::Ethernet => 1,
            HTypes::ExperimentalEthernet => 2,
            HTypes::AmateurRadio => 3,
            HTypes::ProteonTokenRing => 4,
            HTypes::Chaos => 5,
            HTypes::IEEE802 => 6,
            HTypes::ARCNET => 7,
            HTypes::Hyperchannel => 8,
            HTypes::Lanstar => 9,
            HTypes::AutonetShortAddress => 10,
            HTypes::LocalTalk => 11,
            HTypes::LocalNet => 12,
            HTypes::UltraLink => 13,
            HTypes::SMDS => 14,
            HTypes::FrameRelay => 15,
            HTypes::ATM16 => 16,
            HTypes::HDLC => 17,
            HTypes::FibreChannel => 18,
            HTypes::ATM19 => 19,
            HTypes::SerialLine => 20,
            HTypes::ATM21 => 21,
            HTypes::MILSTD188220 => 22,
            HTypes::Metricom => 23,
            HTypes::IEEE13941995 => 24,
            HTypes::MAPOS => 25,
            HTypes::Twinaxial => 26,
            HTypes::EUI64 => 27,
            HTypes::HIPARP => 28,
            HTypes::IPARPISO78163 => 29,
            HTypes::ARPSec => 30,
            HTypes::IPsecTunnel => 31,
            HTypes::InfiniBand => 32,
            HTypes::CommonAirInterface => 33,
            HTypes::WiegandInterface => 34,
            HTypes::PureIP => 35,
            HTypes::HWEXP1 => 36,
            HTypes::HFI => 37,
            HTypes::UnifiedBus => 38,
            HTypes::Other(x) => *x,
        }
    }
}

// Decode
impl From<u8> for HTypes {
    fn from(byte: u8) -> Self {
        match byte {
            1 => Self::Ethernet,
            2 => Self::ExperimentalEthernet,
            3 => Self::AmateurRadio,
            4 => Self::ProteonTokenRing,
            5 => Self::Chaos,
            6 => Self::IEEE802,
            7 => Self::ARCNET,
            8 => Self::Hyperchannel,
            9 => Self::Lanstar,
            10 => Self::AutonetShortAddress,
            11 => Self::LocalTalk,
            12 => Self::LocalNet,
            13 => Self::UltraLink,
            14 => Self::SMDS,
            15 => Self::FrameRelay,
            16 => Self::ATM16,
            17 => Self::HDLC,
            18 => Self::FibreChannel,
            19 => Self::ATM19,
            20 => Self::SerialLine,
            21 => Self::ATM21,
            22 => Self::MILSTD188220,
            23 => Self::Metricom,
            24 => Self::IEEE13941995,
            25 => Self::MAPOS,
            26 => Self::Twinaxial,
            27 => Self::EUI64,
            28 => Self::HIPARP,
            29 => Self::IPARPISO78163,
            30 => Self::ARPSec,
            31 => Self::IPsecTunnel,
            32 => Self::InfiniBand,
            33 => Self::CommonAirInterface,
            34 => Self::WiegandInterface,
            35 => Self::PureIP,
            36 => Self::HWEXP1,
            37 => Self::HFI,
            38 => Self::UnifiedBus,
            _ => Self::Other(byte),
        }
    }
}