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
impl Filter
pub fn new() -> Self
sourcepub fn name(&self) -> String
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.
pub fn set_name(&mut self, name: &str)
sourcepub fn compile(self) -> Result<Self>
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.
sourcepub fn apply_if_match(
&self,
msg: &Message,
db: &Database
) -> Result<(bool, bool)>
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