pub struct Censor {
pub lang: Arc<dyn LangProvider + Send + Sync + 'static>,
pub data: LangData,
pub re_cache: Lazy<Arc<RwLock<HashMap<String, Regex>>>>,
}Fields§
§lang: Arc<dyn LangProvider + Send + Sync + 'static>§data: LangData§re_cache: Lazy<Arc<RwLock<HashMap<String, Regex>>>>Implementations§
Source§impl Censor
impl Censor
pub fn new(lang: CensorLang) -> Result<Self, CensorError>
pub fn from<L>(lang: Arc<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 !Freeze for Censor
impl !RefUnwindSafe for Censor
impl !UnwindSafe for Censor
impl Send for Censor
impl Sync for Censor
impl Unpin for Censor
impl UnsafeUnpin for Censor
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