Function base16::decode
[−]
[src]
pub fn decode<T: ?Sized + AsRef<[u8]>>(
input: &T
) -> Result<Vec<u8>, DecodeError>
Decode bytes from base16, and return a new Vec<u8>
containing the results.
Example
assert_eq!(base16::decode("48656c6c6f20576f726c64".as_bytes()).unwrap(), b"Hello World".to_vec()); assert_eq!(base16::decode(b"deadBEEF").unwrap(), vec![0xde, 0xad, 0xbe, 0xef]); // Error cases: assert_eq!(base16::decode(b"Not Hexadecimal!"), Err(base16::DecodeError::InvalidByte { byte: b'N', index: 0 })); assert_eq!(base16::decode(b"a"), Err(base16::DecodeError::InvalidLength { length: 1 }));