decode
Decodes a hexadecimal string (either case) into bytes.
The string must be made of digit pairs only: surrounding whitespace, a 0x prefix or
separators are errors, so trim or strip them first.
Import
Section titled “Import”Cargo feature hex (enabled by default). To compile only this module:
or in Cargo.toml:
Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
hex | &str | The hexadecimal string to decode. |
Returns
Section titled “Returns”Result<Vec<u8>, DecodeError> — Ok on success, otherwise an Err: see Errors.
Errors
Section titled “Errors”DecodeError::OddLength for an odd number of characters, DecodeError::InvalidChar for
a character that is not a hex digit.
Examples
Section titled “Examples”Error type: DecodeError
Section titled “Error type: DecodeError”Why a string could not be decoded as hexadecimal.
