use crate::redactor::Redactor;
#[derive(Debug)]
pub struct RedactorBuilder {
fields: Vec<String>,
mask: String,
}
impl RedactorBuilder {
pub(crate) fn new() -> Self {
RedactorBuilder {
fields: Vec::new(),
mask: "******".to_string(),
}
}
pub fn field(mut self, name: impl Into<String>) -> Self {
self.fields.push(name.into());
self
}
pub fn fields<I, S>(mut self, names: I) -> Self
where
I: IntoIterator<Item = S>,
S: Into<String>,
{
self.fields.extend(names.into_iter().map(Into::into));
self
}
pub fn mask(mut self, mask: impl Into<String>) -> Self {
self.mask = mask.into();
self
}
pub fn build(self) -> Redactor {
Redactor::from_parts(self.fields, self.mask)
}
}