[−][src]Function base16::decode
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"); assert_eq!(&base16::decode(b"deadBEEF").unwrap(), &[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 }));
Availability
This function is only available when the alloc
feature is enabled, as it
needs to produce a Vec.