use core::fmt;
pub(crate) fn write_hex_bytes(
f: &mut fmt::Formatter,
bytes: &[u8],
) -> fmt::Result {
for byte in bytes {
write!(f, "{byte:02x}")?;
}
Ok(())
}
pub(crate) struct HexStr<'a>(pub(crate) &'a [u8]);
impl fmt::Debug for HexStr<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("\"")?;
write_hex_bytes(f, self.0)?;
f.write_str("\"")
}
}
pub(crate) fn write_hex_tuple(
f: &mut fmt::Formatter,
name: &str,
bytes: &[u8],
) -> fmt::Result {
f.debug_tuple(name).field(&HexStr(bytes)).finish()
}