Struct rustrict::Type

source ·
pub struct Type(/* private fields */);
Expand description

Type is represents a type or severity of inappropriateness. They can be combined with bitwise AND and OR operators, and are not mutually exclusive.

For example, the following means profane or at-least moderately mean: Type::PROFANE | (Type::MEAN & Type::MODERATE_OR_HIGHER)

Implementations§

source§

impl Type

source

pub const PROFANE: Self = _

Bad words.

source

pub const OFFENSIVE: Self = _

Offensive words.

source

pub const SEXUAL: Self = _

Sexual words.

source

pub const MEAN: Self = _

Mean words.

source

pub const EVASIVE: Self = _

Words intended to evade detection.

source

pub const SPAM: Self = _

Spam/gibberish/SHOUTING.

source

pub const SAFE: Self = _

One of a very small number of safe phases. Recommended to enforce this on users who repeatedly evade the filter.

source

pub const MILD: Self = _

Not that bad. (low severity and/or low confidence)

source

pub const MODERATE: Self = _

Bad. (moderate severity and/or moderate confidence)

source

pub const SEVERE: Self = _

Cover your eyes! (high severity and/or high confidence)

source

pub const MILD_OR_HIGHER: Self = _

Any level; Type::MILD, Type::MODERATE, or Type::SEVERE.

source

pub const MODERATE_OR_HIGHER: Self = _

Any level in excess of Type::MILD.

source

pub const INAPPROPRIATE: Self = _

Inappropriate for general audiences (the default Type, meaning profane, offensive, sexual, or severely mean).

source

pub const ANY: Self = _

Any type of detection (except SAFE). This will be expanded to cover all future types.

source

pub const NONE: Self = _

No type of detection.

source

pub fn is(self, threshold: Self) -> bool

Returns true if and only if self, the analysis result, meets the given threshold.

source

pub fn isnt(self, threshold: Self) -> bool

Logical opposite of Self::is.

source

pub fn empty() -> Self

👎Deprecated: this is for backwards-compatibility, use Type::NONE instead
source

pub fn is_empty(self) -> bool

👎Deprecated: this is for backwards-compatibility, compare with Type::NONE instead
source

pub fn bits(self) -> u32

👎Deprecated: this is for backwards-compatibility, there is no replacement

Trait Implementations§

source§

impl BitAnd for Type

§

type Output = Type

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: Self) -> Self::Output

Performs the & operation. Read more
source§

impl BitAndAssign for Type

source§

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
source§

impl BitOr for Type

§

type Output = Type

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: Self) -> Self::Output

Performs the | operation. Read more
source§

impl BitOrAssign for Type

source§

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
source§

impl Clone for Type

source§

fn clone(&self) -> Type

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Type

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Type

source§

fn default() -> Self

Returns a reasonable default for censoring or blocking.

source§

impl Hash for Type

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Not for Type

§

type Output = Type

The resulting type after applying the ! operator.
source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
source§

impl PartialEq for Type

source§

fn eq(&self, other: &Type) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Type

source§

impl Eq for Type

source§

impl StructuralEq for Type

source§

impl StructuralPartialEq for Type

Auto Trait Implementations§

§

impl RefUnwindSafe for Type

§

impl Send for Type

§

impl Sync for Type

§

impl Unpin for Type

§

impl UnwindSafe for Type

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.