1use std::fmt::Formatter;
2
3use crate::{Obfuscate, compute_hash};
4
5impl Obfuscate for [u8] {
6 fn obfuscate(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
7 f.write_str(hex::encode(compute_hash(self)).as_str())
8 }
9}
10
11impl Obfuscate for Vec<u8> {
12 fn obfuscate(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
13 (**self).obfuscate(f)
14 }
15}
16
17impl<T: Obfuscate> Obfuscate for Vec<T> {
18 fn obfuscate(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
19 f.write_str("[")?;
20 for item in self.iter() {
21 item.obfuscate(f)?;
22 }
23 f.write_str("]")
24 }
25}
26
27impl<T: Obfuscate> Obfuscate for Option<T> {
28 fn obfuscate(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
29 match self {
30 Some(item) => {
31 f.write_str("Some(")?;
32 item.obfuscate(f)?;
33 f.write_str(")")
34 }
35 None => f.write_str("None"),
36 }
37 }
38}