pub fn key_to_hex<const N: usize>(key: DataRefType<'_, N>) -> Option<String>
Expand description
Converts a DataType
array into a hexadecimal string.
This function takes a DataType
array (key
) and converts it into its corresponding
hexadecimal string representation. If the key is None
, it returns None
.
§Type Parameters:
N
: The size of theDataType
array. This is a constant array length that ensures type safety.
§Arguments:
key
: A reference to aDataType
array of sizeN
. This is the key to be encoded into a hexadecimal string. It must be a valid key array of the appropriate size.
§Returns:
Some(String)
: The hexadecimal string representation of the key if the key isSome
. ReturnsNone
if the key isNone
.
§Example:
let key = Some([0xa1, 0xb2, 0xc3, 0xd4, 0xe5, 0xf6, 0x78, 0x90]);
let hexstr = key_to_hex(key);
assert_eq!(hexstr, Some("a1b2c3d4e5f67890".to_string()));