decode_array
Decodes a hexadecimal string into a fixed-size array, e.g. a 32-byte key from 64 hex digits.
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; must encode exactly N bytes. |
Returns
Section titled “Returns”Result<[u8; N], DecodeError> — Ok on success, otherwise an Err: see Errors.
Errors
Section titled “Errors”Same as decode_to_slice: the string must have exactly 2 * N
hex digits.
Examples
Section titled “Examples”Error type: DecodeError
Section titled “Error type: DecodeError”Why a string could not be decoded as hexadecimal.
