pub fn hex_check(src: &[u8]) -> boolExpand description
Returns whether every byte is an ASCII hex digit, accepting either letter case.
Accepts 0 through 9, a through f, and A through F, including mixed
case. Prefixes, whitespace and non-ASCII bytes are rejected. This is a
character-only check: empty and odd-length inputs can pass. It does not
allocate or modify the input.
Use hex_decode to also require complete byte pairs. There is no need to
call this function before a checked decoder: decoding already validates input.
ยงExamples
use faster_hex::hex_check;
assert!(hex_check(b"00aBcD"));
assert!(hex_check(b"a")); // Valid characters, but not a complete byte pair.
assert!(hex_check(b""));
assert!(!hex_check(b"0x01"));
assert!(!hex_check(b"00 01"));