pub fn hex_to_bytes(hex: &str) -> Result<Vec<u8>, String>Expand description
Converts a hexadecimal string to its byte representation.
This function takes a string slice containing a hexadecimal representation
and returns a Vec
§Arguments
hex- A string slice containing the hexadecimal representation to convert.
§Returns
A Result containing either:
- Ok(Vec
): The byte representation of the input hexadecimal string. - Err(String): An error message if the input is invalid.
§Example
let bytes = byteutils::hex_to_bytes("0fff0080").unwrap();
assert_eq!(byteutils::hex_to_bytes("0fff0080").unwrap(), vec![15, 255, 0, 128]);