fn validate_option(octets: &[u8]) -> Result<usize, ReadRdataError> {
    if let Some(len_octets) = octets.get(2..4) {
        let len = u16::from_be_bytes([len_octets[0], len_octets[1]]) as usize;
        if octets.len() >= len + 4 {
            Ok(len + 4)
        } else {
            Err(ReadRdataError::Other)
        }
    } else {
        Err(ReadRdataError::Other)
    }
}
/// Validates a single option in an OPT record's RDATA.
Validates a single option in an OPT record's RDATA.
Validates a single option in an OPT record ' s RDATA .
fn validate_option(octets: &[u8]) -> Result<usize, ReadRdataError> {
    if let Some(len_octets) = octets.get(2..4) {
        let len = u16::from_be_bytes([len_octets[0], len_octets[1]]) as usize;
        if octets.len() >= len + 4 {
            Ok(len + 4)
        } else {
            Err(ReadRdataError::Other)
        }
    } else {
        Err(ReadRdataError::Other)
    }
}
fn validate_option ( octets : & [ u8 ] ) -> Result < usize , ReadRdataError > { if let Some ( len_octets ) = octets . get ( 2 .. 4 ) { let len = u16 :: from_be_bytes ( [ len_octets [ 0 ] , len_octets [ 1 ] ] ) as usize ; if octets . len ( ) >= len + 4 { Ok ( len + 4 ) } else { Err ( ReadRdataError :: Other ) } } else { Err ( ReadRdataError :: Other ) } }
Validates a single option in an OPT record's RDATA.
Validates a single option in an OPT record ' s RDATA .
octets
&[u8]
octets
&[u8]