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