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
sourceimpl 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<T>(
&self,
msg: &Message<'_, T>,
db: &Database
) -> Result<(bool, bool)>where
T: MessageOwner,
pub fn apply_if_match<T>(
&self,
msg: &Message<'_, T>,
db: &Database
) -> Result<(bool, bool)>where
T: MessageOwner,
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
sourcepub fn is_match<T>(&self, msg: &Message<'_, T>, db: &Database) -> Result<bool>where
T: MessageOwner,
pub fn is_match<T>(&self, msg: &Message<'_, T>, db: &Database) -> Result<bool>where
T: MessageOwner,
Checks if the supplied message matches any of the combinations described
in Filter::rules
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Filter
impl<'de> Deserialize<'de> for Filter
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations
impl RefUnwindSafe for Filter
impl Send for Filter
impl Sync for Filter
impl Unpin for Filter
impl UnwindSafe for Filter
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> SafeBorrow<T> for Twhere
T: ?Sized,
impl<T> SafeBorrow<T> for Twhere
T: ?Sized,
fn borrow_replacement(ptr: &T) -> &T
fn borrow_replacement(ptr: &T) -> &T
ptr
, which was obtained from a prior call to Self::borrow()
,
return a value with the same nominal lifetime which is guaranteed to
survive mutations to Self
. Read more