pub enum Rule<Ctx: ?Sized + 'static> {
Any(Vec<Self>),
All(Vec<Self>),
Not(Box<Self>),
Leaf(Condition<Ctx>),
}
Expand description
Represents a rule, which can be a condition or a logical combination of other rules.
Rules can be composed using logical operators:
Any
: At least one sub-rule must evaluate totrue
All
: All sub-rules must evaluate totrue
Not
: Negates the result of the contained ruleLeaf
: A single condition that evaluates to a boolean
Variants§
Implementations§
Source§impl<Ctx: ?Sized> Rule<Ctx>
impl<Ctx: ?Sized> Rule<Ctx>
Sourcepub fn evaluate(&self, context: &Ctx) -> StdResult<bool, Box<dyn StdError>>
pub fn evaluate(&self, context: &Ctx) -> StdResult<bool, Box<dyn StdError>>
Evaluates a rule synchronously using the provided context.
This method evaluates the rule against the provided context and returns a boolean result indicating whether the rule matched. If the rule contains any async operations, this method will return an error.
Sourcepub async fn evaluate_async(
&self,
context: &Ctx,
) -> StdResult<bool, Box<dyn StdError>>
pub async fn evaluate_async( &self, context: &Ctx, ) -> StdResult<bool, Box<dyn StdError>>
Evaluates a rule asynchronously using the provided context.
This method evaluates the rule against the provided context and returns a boolean result indicating whether the rule matched. It supports rules containing both synchronous and asynchronous operations.
Trait Implementations§
Auto Trait Implementations§
impl<Ctx> Freeze for Rule<Ctx>where
Ctx: ?Sized,
impl<Ctx> !RefUnwindSafe for Rule<Ctx>
impl<Ctx> !Send for Rule<Ctx>
impl<Ctx> !Sync for Rule<Ctx>
impl<Ctx> Unpin for Rule<Ctx>where
Ctx: ?Sized,
impl<Ctx> !UnwindSafe for Rule<Ctx>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more