multiversx_sc/formatter/
formatter_impl_bytes.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use super::{
    hex_util::{byte_to_binary_digits, encode_bytes_as_hex},
    FormatByteReceiver, SCBinary, SCDisplay, SCLowerHex,
};

impl SCDisplay for &[u8] {
    fn fmt<F: FormatByteReceiver>(&self, f: &mut F) {
        f.append_bytes(self);
    }
}

impl SCLowerHex for &[u8] {
    fn fmt<F: FormatByteReceiver>(&self, f: &mut F) {
        f.append_bytes(encode_bytes_as_hex(self).as_bytes());
    }
}

impl SCBinary for &[u8] {
    fn fmt<F: FormatByteReceiver>(&self, f: &mut F) {
        for b in self.iter() {
            f.append_bytes(&byte_to_binary_digits(*b));
        }
    }
}