decode

Function decode 

Source
pub fn decode(s: &str) -> Result<Vec<u8>, DecodeError>
Expand description

Decode hex string to bytes.

Returns an error for invalid hex characters or odd-length strings.

ยงExamples

use async_snmp::format::hex::decode;

assert_eq!(decode("deadbeef").unwrap(), vec![0xde, 0xad, 0xbe, 0xef]);
assert_eq!(decode("00FF").unwrap(), vec![0x00, 0xff]);
assert!(decode("xyz").is_err());
assert!(decode("abc").is_err()); // odd length