dredd_rs/
engine.rs

1use crate::rule::{Rule, RuleContext, RuleResult};
2use crate::runner::{
3    best_first_rule_runner::BestFirstRuleRunner, chain_rule_runner::ChainRuleRunner, RuleRunner,
4};
5
6/// The Engine provides convenient methods for rule execution
7pub struct Engine;
8
9impl Engine {
10    /// Get a BestFirstRuleRunner instance
11    pub fn best_first_runner() -> BestFirstRuleRunner {
12        BestFirstRuleRunner
13    }
14
15    /// Get a ChainRuleRunner instance  
16    pub fn chain_runner() -> ChainRuleRunner {
17        ChainRuleRunner
18    }
19
20    /// Execute rules using the best-first strategy
21    pub fn execute_best_first(
22        context: &mut RuleContext,
23        rules: &mut [Box<dyn Rule>],
24    ) -> RuleResult<()> {
25        Self::best_first_runner().run(context, rules)
26    }
27
28    /// Execute rules using the chain strategy
29    pub fn execute_chain(context: &mut RuleContext, rules: &mut [Box<dyn Rule>]) -> RuleResult<()> {
30        Self::chain_runner().run(context, rules)
31    }
32}