2019-09-05 14:00:23 -07:00
|
|
|
use core::fmt::{Formatter, LowerHex, Result, UpperHex};
|
2019-07-31 07:50:57 +08:00
|
|
|
|
2020-01-24 02:08:40 +08:00
|
|
|
use super::BytesRef;
|
2020-05-22 13:17:30 +09:00
|
|
|
use crate::{Bytes, BytesMut};
|
2019-07-31 07:50:57 +08:00
|
|
|
|
2020-01-24 02:08:40 +08:00
|
|
|
impl LowerHex for BytesRef<'_> {
|
2019-07-31 07:50:57 +08:00
|
|
|
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
|
2020-01-24 02:08:40 +08:00
|
|
|
for &b in self.0 {
|
2019-07-31 07:50:57 +08:00
|
|
|
write!(f, "{:02x}", b)?;
|
|
|
|
|
}
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-24 02:08:40 +08:00
|
|
|
impl UpperHex for BytesRef<'_> {
|
2019-07-31 07:50:57 +08:00
|
|
|
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
|
2020-01-24 02:08:40 +08:00
|
|
|
for &b in self.0 {
|
2019-07-31 07:50:57 +08:00
|
|
|
write!(f, "{:02X}", b)?;
|
|
|
|
|
}
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-08 10:23:02 +01:00
|
|
|
fmt_impl!(LowerHex, Bytes);
|
|
|
|
|
fmt_impl!(LowerHex, BytesMut);
|
|
|
|
|
fmt_impl!(UpperHex, Bytes);
|
|
|
|
|
fmt_impl!(UpperHex, BytesMut);
|