Struct notcoal::Filter

source ·
pub struct Filter {
    pub desc: Option<String>,
    pub rules: Vec<BTreeMap<String, Value>>,
    pub op: Operations,
    /* private fields */
}

Fields§

§desc: Option<String>

Description

Not really used for anything at this point in time, but may be good for users to remember what this specific filter is doing

§rules: Vec<BTreeMap<String, Value>>

List of rules

This list is an OR list, meaning the filter will match if any rule matches. However, AND combinations may happen within a rule

§op: Operations

Operations that will be applied if this any rule matches

Implementations§

source§

impl Filter

source

pub fn new() -> Self

source

pub fn name(&self) -> String

Returns either the set name, or a hash of Filter::rules. Please note: hashed names are not used for serialization.

source

pub fn set_name(&mut self, name: &str)

source

pub fn compile(self) -> Result<Self>

When filters are deserialized from json or have been assembled via code, the regular expressions contained in Filter::rules need to be compiled before any matches are to be made.

source

pub fn apply_if_match( &self, msg: &Message, db: &Database ) -> Result<(bool, bool)>

Combines Filter::is_match and Operations::apply

Returns a tuple of two bools, the first representing if the filter has been applied, the second if the operation deleted the message that was supplied

source

pub fn is_match(&self, msg: &Message, db: &Database) -> Result<bool>

Checks if the supplied message matches any of the combinations described in Filter::rules

Trait Implementations§

source§

impl Debug for Filter

source§

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

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

impl Default for Filter

source§

fn default() -> Filter

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Filter

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Serialize for Filter

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Filter

§

impl RefUnwindSafe for Filter

§

impl Send for Filter

§

impl Sync for Filter

§

impl Unpin for Filter

§

impl UnwindSafe for Filter

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

§

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.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,