pub fn request_from_bytes(bytes: T) -> Result<Self, Error> {
        // This kind of frame has a fixed length, so we know what to expect.
        if bytes.len() != ETH_IPV4_FRAME_LEN {
            return Err(Error::SliceExactLen);
        }

        let maybe = EthIPv4ArpFrame::from_bytes_unchecked(bytes);

        if maybe.htype() != HTYPE_ETHERNET {
            return Err(Error::HType);
        }

        if maybe.ptype() != ETHERTYPE_IPV4 {
            return Err(Error::PType);
        }

        // We could theoretically skip the hlen and plen checks, since they are kinda implicit.
        if maybe.hlen() != MAC_ADDR_LEN as u8 {
            return Err(Error::HLen);
        }

        if maybe.plen() != IPV4_ADDR_LEN as u8 {
            return Err(Error::PLen);
        }

        if maybe.operation() != OPER_REQUEST {
            return Err(Error::Operation);
        }

        Ok(maybe)
    }
/// Tries to interpret a byte slice as a valid IPv4 over Ethernet ARP request.
///
/// If no error occurs, it guarantees accessor methods (which make use of various `_unchecked`
/// functions) are safe to call on the result, because all predefined offsets will be valid.
Tries to interpret a byte slice as a valid IPv4 over Ethernet ARP request.
If no error occurs, it guarantees accessor methods (which make use of various `_unchecked`
functions) are safe to call on the result, because all predefined offsets will be valid.
Tries to interpret a byte slice as a valid IPv4 over Ethernet ARP request . If no error occurs it guarantees accessor methods ( which make use of various ` _unchecked ` functions ) are safe to call on the result because all predefined offsets will be valid .
pub fn request_from_bytes(bytes: T) -> Result<Self, Error> {
        // This kind of frame has a fixed length, so we know what to expect.
        if bytes.len() != ETH_IPV4_FRAME_LEN {
            return Err(Error::SliceExactLen);
        }
        let maybe = EthIPv4ArpFrame::from_bytes_unchecked(bytes);
        if maybe.htype() != HTYPE_ETHERNET {
            return Err(Error::HType);
        }
        if maybe.ptype() != ETHERTYPE_IPV4 {
            return Err(Error::PType);
        }
        // We could theoretically skip the hlen and plen checks, since they are kinda implicit.
        if maybe.hlen() != MAC_ADDR_LEN as u8 {
            return Err(Error::HLen);
        }
        if maybe.plen() != IPV4_ADDR_LEN as u8 {
            return Err(Error::PLen);
        }
        if maybe.operation() != OPER_REQUEST {
            return Err(Error::Operation);
        }
        Ok(maybe)
    }
pub fn request_from_bytes ( bytes : T ) -> Result < Self , Error > { // This kind of frame has a fixed length, so we know what to expect. if bytes . len ( ) != ETH_IPV4_FRAME_LEN { return Err ( Error :: SliceExactLen ) ; } let maybe = EthIPv4ArpFrame :: from_bytes_unchecked ( bytes ) ; if maybe . htype ( ) != HTYPE_ETHERNET { return Err ( Error :: HType ) ; } if maybe . ptype ( ) != ETHERTYPE_IPV4 { return Err ( Error :: PType ) ; } // We could theoretically skip the hlen and plen checks, since they are kinda implicit. if maybe . hlen ( ) != MAC_ADDR_LEN as u8 { return Err ( Error :: HLen ) ; } if maybe . plen ( ) != IPV4_ADDR_LEN as u8 { return Err ( Error :: PLen ) ; } if maybe . operation ( ) != OPER_REQUEST { return Err ( Error :: Operation ) ; } Ok ( maybe ) }
Tries to interpret a byte slice as a valid IPv4 over Ethernet ARP request.
Tries to interpret a byte slice as a valid IPv4 over Ethernet ARP request .
bytes
T
bytes
T