pub struct Censor<'a, L: LangProvider> {
pub lang: &'a L,
pub data: LangData,
pub re_cache: Lazy<Arc<RwLock<HashMap<String, Regex>>>>,
}Fields§
§lang: &'a L§data: LangData§re_cache: Lazy<Arc<RwLock<HashMap<String, Regex>>>>Implementations§
Source§impl<'a, L: LangProvider> Censor<'a, L>
impl<'a, L: LangProvider> Censor<'a, L>
pub fn new(lang: &'a L) -> Result<Self, CensorError>
pub fn precompile_all_patterns(&self)
pub fn precompile_foul_data(&self)
pub fn precompile_foul_core(&self)
pub fn precompile_bad_phrases(&self)
pub fn precompile_bad_semi_phrases(&self)
pub fn precompile_excludes_core(&self)
pub fn precompile_excludes_data(&self)
pub fn is_word_good(&self, raw: &str) -> bool
Sourcepub fn clean_line(&self, line: &str) -> CleanLineResult
pub fn clean_line(&self, line: &str) -> CleanLineResult
returns replaced line plus counts
Sourcepub fn clean_html_line(&self, line: &str) -> CleanHtmlResult
pub fn clean_html_line(&self, line: &str) -> CleanHtmlResult
Clean an HTML string while preserving tags and replacing bad words with beep_html.
@TODO: Rewrite the implementation, so it’ll work with any HTML tags (incl broken etc).
Use a proper HTML parser like scraper or kuchiki
Auto Trait Implementations§
impl<'a, L> !Freeze for Censor<'a, L>
impl<'a, L> !RefUnwindSafe for Censor<'a, L>
impl<'a, L> Send for Censor<'a, L>where
L: Sync,
impl<'a, L> Sync for Censor<'a, L>where
L: Sync,
impl<'a, L> Unpin for Censor<'a, L>
impl<'a, L> !UnwindSafe for Censor<'a, L>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more