decode_to_slice
Decodes a hexadecimal string into out, which must be exactly half as long as the string.
Nothing is allocated; on error out may be partially written.
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. |
out | &mut [u8] | The buffer to decode into; must be exactly half of hex’s length. |
Returns
Section titled “Returns”Result<(), DecodeError> — Ok on success, otherwise an Err: see Errors.
Errors
Section titled “Errors”DecodeError::OddLength, DecodeError::InvalidLength when the string does not match
out.len() * 2, or DecodeError::InvalidChar.
Examples
Section titled “Examples”Error type: DecodeError
Section titled “Error type: DecodeError”Why a string could not be decoded as hexadecimal.
