pub fn decode(value: &str) -> Result<Vec<u8>, DecodeHexError>Expand description
Decodes a hex string prefixed with 0x into raw bytes.
Both, upper and lower case characters are valid in the input string and can
even be mixed (e.g. 0xf9b4ca, 0xF9B4CA and 0xf9B4Ca are all valid strings).
ยงExample
use dcl_crypto::account::{decode, DecodeHexError};
assert_eq!(
decode("0x48656c6c6f20776f726c6421"),
Ok("Hello world!".to_owned().into_bytes())
);
assert_eq!(decode("123"), Err(DecodeHexError::MissingPrefix));
assert_eq!(decode("0x123"), Err(DecodeHexError::OddLength));
assert_eq!(decode("0xfo"), Err(DecodeHexError::InvalidHexCharacter { c: 'o', index: 3 }));