Function decode
Source pub fn decode<T: FromHexPrefixed>(hex: impl AsRef<str>) -> Result<T, Error>
Expand description
Decodes a hex string with 0x prefix into a type T.
§Decode into Vec<u8>
let result = prefix_hex::decode("0x000102");
assert_eq!(result, Ok(vec![0x0, 0x1, 0x2]));
§Decode into [u8;N]
let result = prefix_hex::decode("0x000102");
assert_eq!(result, Ok([0x0, 0x1, 0x2]));