pub fn redact_text<'t>(&self, text: &'t str) -> Cow<'t, str> {
        let mut redacted = Cow::Borrowed(text);
        for idx in self.to_redact.matches(text) {
            let replacer = &self.replacements[idx];
            redacted = Cow::Owned(
                match replacer.use_map {
                    MapType::No => replacer.matcher.replace_all(&redacted, replacer.replacement),
                    MapType::ReplaceAll => {
                        replacer.matcher.replace_all(&redacted, |caps: &'_ Captures<'_>| {
                            let mut cache = self.redaction_cache.lock();
                            let id = cache.get_id(caps[0].to_string());
                            replacer.replacement.replace("{}", &id)
                        })
                    }
                    MapType::Mac => {
                        replacer.matcher.replace_all(&redacted, |caps: &'_ Captures<'_>| {
                            let oui = caps.name("oui");
                            let mut cache = self.redaction_cache.lock();
                            let id = cache.get_id(caps[0].to_string());
                            format!(
                                "{}<{}{}>",
                                oui.map_or("regex error", |o| o.as_str()),
                                replacer.replacement,
                                id
                            )
                        })
                    }
                }
                .to_string(),
            );
        }
        redacted
    }
/// Replace any instances of this redactor's patterns with the value of [`REPLACEMENT`].
Replace any instances of this redactor's patterns with the value of [`REPLACEMENT`].
Replace any instances of this redactor ' s patterns with the value of [ ` REPLACEMENT ` ] .
pub fn redact_text<'t>(&self, text: &'t str) -> Cow<'t, str> {
        let mut redacted = Cow::Borrowed(text);
        for idx in self.to_redact.matches(text) {
            let replacer = &self.replacements[idx];
            redacted = Cow::Owned(
                match replacer.use_map {
                    MapType::No => replacer.matcher.replace_all(&redacted, replacer.replacement),
                    MapType::ReplaceAll => {
                        replacer.matcher.replace_all(&redacted, |caps: &'_ Captures<'_>| {
                            let mut cache = self.redaction_cache.lock();
                            let id = cache.get_id(caps[0].to_string());
                            replacer.replacement.replace("{}", &id)
                        })
                    }
                    MapType::Mac => {
                        replacer.matcher.replace_all(&redacted, |caps: &'_ Captures<'_>| {
                            let oui = caps.name("oui");
                            let mut cache = self.redaction_cache.lock();
                            let id = cache.get_id(caps[0].to_string());
                            format!(
                                "{}<{}{}>",
                                oui.map_or("regex error", |o| o.as_str()),
                                replacer.replacement,
                                id
                            )
                        })
                    }
                }
                .to_string(),
            );
        }
        redacted
    }
pub fn redact_text < ' t > ( & self , text : & ' t str ) -> Cow < ' t , str > { let mut redacted = Cow :: Borrowed ( text ) ; for idx in self . to_redact . matches ( text ) { let replacer = & self . replacements [ idx ] ; redacted = Cow :: Owned ( match replacer . use_map { MapType :: No => replacer . matcher . replace_all ( & redacted , replacer . replacement ) , MapType :: ReplaceAll => { replacer . matcher . replace_all ( & redacted , | caps : & ' _ Captures < ' _ > | { let mut cache = self . redaction_cache . lock ( ) ; let id = cache . get_id ( caps [ 0 ] . to_string ( ) ) ; replacer . replacement . replace ( " " , & id ) } ) } MapType :: Mac => { replacer . matcher . replace_all ( & redacted , | caps : & ' _ Captures < ' _ > | { let oui = caps . name ( " " ) ; let mut cache = self . redaction_cache . lock ( ) ; let id = cache . get_id ( caps [ 0 ] . to_string ( ) ) ; format ! ( " " oui map_or ( " " o o as_str ( ) ) replacer replacement id ) } ) } } . to_string ( ) , ) ; } redacted }
Replace any instances of this redactor's patterns with the value of [`REPLACEMENT`].
Replace any instances of this redactor ' s patterns with the value of [ ` REPLACEMENT ` ] .
&self
text
&'t str
&self
text
&'t str