cross_authenticode/
hex_ex.rs1pub trait ToHex {
3 fn to_hex(&self) -> String;
5 fn to_lower_hex(&self) -> String;
7 fn to_upper_hex(&self) -> String;
9}
10
11impl ToHex for &[u8] {
12 fn to_hex(&self) -> String {
13 self.to_lower_hex()
14 }
15 fn to_lower_hex(&self) -> String {
16 use std::fmt::Write;
17 self.iter().fold(String::new(), |mut output, b| {
18 let _ = write!(output, "{b:02x}");
19 output
20 })
21 }
22 fn to_upper_hex(&self) -> String {
23 use std::fmt::Write;
24 self.iter().fold(String::new(), |mut output, b| {
25 let _ = write!(output, "{b:02X}");
26 output
27 })
28 }
29}
30
31impl ToHex for Vec<u8> {
32 fn to_hex(&self) -> String {
33 self.to_lower_hex()
34 }
35
36 fn to_lower_hex(&self) -> String {
37 self.as_slice().to_lower_hex()
38 }
39
40 fn to_upper_hex(&self) -> String {
41 self.as_slice().to_upper_hex()
42 }
43}