Skip to main content

Censor

Struct Censor 

Source
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

Source

pub fn new(lang: CensorLang) -> Result<Self, CensorError>

Source

pub fn from<L>(lang: Arc<L>) -> Result<Self, CensorError>
where L: LangProvider + Send + Sync + 'static,

Source

pub fn precompile_all_patterns(&self)

Source

pub fn precompile_foul_data(&self)

Source

pub fn precompile_foul_core(&self)

Source

pub fn precompile_bad_phrases(&self)

Source

pub fn precompile_bad_semi_phrases(&self)

Source

pub fn precompile_excludes_core(&self)

Source

pub fn precompile_excludes_data(&self)

Source

pub fn is_word_good(&self, raw: &str) -> bool

Source

pub fn clean_line(&self, line: &str) -> CleanLineResult

returns replaced line plus counts

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.