Skip to main content

decode_into

Function decode_into 

Source
pub fn decode_into(
    output: &mut [u8],
    encoded_data: &[u8],
) -> Result<(), DecodeError>
Expand description

Decodes a hex string into an existing buffer.

Dispatches to a SIMD-accelerated implementation (AVX2 or NEON) when the target feature is available.

Accepts any combination of uppercase and lowercase hex characters.

See decode_into_constant_time for security-sensitive and cryptographic operations.

§Errors

Returns DecodeError if any character is not a valid hex digit or if the input length is odd or if output.len() != encoded_data.len() / 2.

§Example

let mut buf = [0u8; 5];
hex::decode_into(&mut buf, b"68656c6c6f").unwrap();
assert_eq!(&buf, b"hello");