Skip to main content

decode

Function decode 

Source
pub fn decode(data: impl AsRef<[u8]>) -> Result<Vec<u8>, DecodeError>
Available on crate features alloc only.
Expand description

Decode Decodes a hex string into bytes.

Accepts any combination of uppercase and lowercase hex characters.

§Errors

Returns DecodeError if any character is not a valid or if the input has an odd number of characters.

§Example

let decoded = hex::decode(b"68656c6c6f").unwrap();
assert_eq!(decoded, b"hello");