1 2 3 4 5 6 7 8 9
use hex::FromHexError; pub fn to_hex(data: &[u8]) -> String { format!("0x{}", hex::encode(data)) } pub fn from_hex(data: &str) -> Result<Vec<u8>, FromHexError> { hex::decode(&data[2..]) }