pub(crate) fn hex_digit_to_int(digit: u8) -> Option<u8> {
match digit {
b'0' => Some(0x0),
b'1' => Some(0x1),
b'2' => Some(0x2),
b'3' => Some(0x3),
b'4' => Some(0x4),
b'5' => Some(0x5),
b'6' => Some(0x6),
b'7' => Some(0x7),
b'8' => Some(0x8),
b'9' => Some(0x9),
b'a' | b'A' => Some(0xa),
b'b' | b'B' => Some(0xb),
b'c' | b'C' => Some(0xc),
b'd' | b'D' => Some(0xd),
b'e' | b'E' => Some(0xe),
b'f' | b'F' => Some(0xf),
_ => None,
}
}
pub(crate) fn consume_hex_digits(data: &[u8]) -> (&[u8], &[u8]) {
let i = data
.iter()
.position(|&b| hex_digit_to_int(b).is_none())
.unwrap_or_else(|| data.len());
data.split_at(i)
}