#[derive(Clone, PartialEq, Eq)]
pub struct Redacted<T>(pub T);
impl<T: AsRef<[u8]>> core::fmt::Debug for Redacted<T> {
fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(formatter, "Redacted({} bytes)", self.0.as_ref().len())
}
}
#[cfg(test)]
mod tests {
use super::Redacted;
use crate::credential_debug_tests::{shows_none_of, token_shaped};
#[test]
fn redacted_debug_shows_the_length_and_no_byte() {
let bytes = token_shaped::<32>(32);
assert_eq!(format!("{:?}", Redacted(bytes)), "Redacted(32 bytes)");
shows_none_of(&Redacted(bytes), &bytes);
shows_none_of(&Redacted(bytes.to_vec()), &bytes);
}
}