use crate::redaction::{redact::RedactableMapper, traits::RedactableWithMapper};
impl<T> RedactableWithMapper for Option<T>
where
T: RedactableWithMapper,
{
fn redact_with<M: RedactableMapper>(self, mapper: &M) -> Self {
self.map(|value| value.redact_with(mapper))
}
}
impl<T, E> RedactableWithMapper for Result<T, E>
where
T: RedactableWithMapper,
E: RedactableWithMapper,
{
fn redact_with<M: RedactableMapper>(self, mapper: &M) -> Self {
match self {
Ok(value) => Ok(value.redact_with(mapper)),
Err(err) => Err(err.redact_with(mapper)),
}
}
}
impl<T> RedactableWithMapper for Vec<T>
where
T: RedactableWithMapper,
{
fn redact_with<M: RedactableMapper>(self, mapper: &M) -> Self {
self.into_iter()
.map(|value| value.redact_with(mapper))
.collect()
}
}
impl<T> RedactableWithMapper for Box<T>
where
T: RedactableWithMapper,
{
fn redact_with<M: RedactableMapper>(self, mapper: &M) -> Self {
Box::new((*self).redact_with(mapper))
}
}
impl<T> RedactableWithMapper for std::sync::Arc<T>
where
T: RedactableWithMapper + Clone,
{
fn redact_with<M: RedactableMapper>(self, mapper: &M) -> Self {
std::sync::Arc::new((*self).clone().redact_with(mapper))
}
}
impl<T> RedactableWithMapper for std::rc::Rc<T>
where
T: RedactableWithMapper + Clone,
{
fn redact_with<M: RedactableMapper>(self, mapper: &M) -> Self {
std::rc::Rc::new((*self).clone().redact_with(mapper))
}
}