use crate::{
RedactValueMut,
RedactionPolicy,
policy::ResolvedField,
};
pub trait RedactMapValueMut<K: ?Sized, V: ?Sized> {
fn redact_map_in_place(&mut self, policy: &RedactionPolicy);
}
impl<M: ?Sized, K: ?Sized, V: ?Sized> RedactMapValueMut<K, V> for M
where
for<'a> &'a mut M: IntoIterator<Item = (&'a K, &'a mut V)>,
K: AsRef<str>,
V: RedactValueMut,
{
#[inline]
fn redact_map_in_place(&mut self, policy: &RedactionPolicy) {
for (key, value) in self {
let resolved = policy.resolve_field(key.as_ref());
if let ResolvedField::Sensitive { sensitivity } = resolved {
value.redact_value_in_place(sensitivity, policy.masking());
}
}
}
}