pub trait Rule {
// Required methods
fn call(&self, msg: &Message) -> bool;
fn reset(&self);
}Expand description
Data returned by the rule function of a module. This trait is used to define the rules that determine whether a message should be processed by a module. It allows for flexible and reusable rules that can be applied to different modules. The rules can be implemented as standalone functions or as methods on the module itself. The rules should be lightweight and efficient, as they will be called for every incoming message. The rules should not perform any blocking operations and should be designed to be as efficient as possible to avoid slowing down the message processing pipeline. The rules can be used to filter messages, transform them, or perform any other necessary operations
Required Methods§
Sourcefn call(&self, msg: &Message) -> bool
fn call(&self, msg: &Message) -> bool
Validate wherever the messsage follows the rule and needs to be processed by this module.
Sourcefn reset(&self)
fn reset(&self)
Resets the rule to its initial state. This is useful for rules that maintain state and need to be reset when the module is reset or reinitialized. Implementations should ensure that the rule is in a clean state after this call.
§Note
This method is not required to be asynchronous, as it is expected to be a lightweight operation that does not involve any I/O or long-running tasks. It should be implemented in a way that allows the rule to be reused without needing to recreate it, thus improving performance and reducing overhead.