Skip to main content

hex_decode_vec_with_case

Function hex_decode_vec_with_case 

Source
pub fn hex_decode_vec_with_case(
    src: &[u8],
    check_case: CheckCase,
) -> Result<Vec<u8>, Error>
Available on crate feature alloc only.
Expand description

Decodes the complete input into a new vector using a letter-case policy.

Available with alloc. Ownership, grammar and allocation behavior are the same as hex_decode_vec. Digits are accepted under every policy.

§Errors

Returns Error::OddLength before allocation, then Error::InvalidChar for the first invalid byte or disallowed letter. As with hex_decode_vec, allocation failure is not returned as a codec error and no size limit is imposed.

§Examples

use faster_hex::{hex_decode_vec_with_case, CheckCase};

assert_eq!(hex_decode_vec_with_case(b"AB01", CheckCase::Upper)?, [0xab, 1]);
assert!(hex_decode_vec_with_case(b"ab01", CheckCase::Upper).is_err());