drt_sc/formatter/
formatter_impl_bytes.rs

1use super::{
2    hex_util::{byte_to_binary_digits, encode_bytes_as_hex},
3    FormatByteReceiver, SCBinary, SCDisplay, SCLowerHex,
4};
5
6impl SCDisplay for &[u8] {
7    fn fmt<F: FormatByteReceiver>(&self, f: &mut F) {
8        f.append_bytes(self);
9    }
10}
11
12impl SCLowerHex for &[u8] {
13    fn fmt<F: FormatByteReceiver>(&self, f: &mut F) {
14        f.append_bytes(encode_bytes_as_hex(self).as_bytes());
15    }
16}
17
18impl SCBinary for &[u8] {
19    fn fmt<F: FormatByteReceiver>(&self, f: &mut F) {
20        for b in self.iter() {
21            f.append_bytes(&byte_to_binary_digits(*b));
22        }
23    }
24}