pub struct RuleEngineBuilder { /* private fields */ }Expand description
Builder pattern for creating a RustRuleEngine with various configurations.
Provides a fluent interface for configuring and building rule engines with rules loaded from files or inline GRL strings.
§Examples
use rust_rule_engine::RuleEngineBuilder;
// Build engine with inline rules
let engine = RuleEngineBuilder::new()
.with_inline_grl(r#"
rule "VIP Check" {
when user.points > 1000
then user.vip = true;
}
"#)?
.build();Implementations§
Source§impl RuleEngineBuilder
impl RuleEngineBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new RuleEngineBuilder with default configuration.
Creates an empty knowledge base named “DefaultKB” and default engine configuration.
Sourcepub fn with_rule_file<P: AsRef<Path>>(self, path: P) -> Result<Self>
pub fn with_rule_file<P: AsRef<Path>>(self, path: P) -> Result<Self>
Add rules from a .grl file.
Reads and parses GRL rules from the specified file path.
§Errors
Returns an error if the file cannot be read or if the GRL syntax is invalid.
Sourcepub fn with_inline_grl(self, grl_content: &str) -> Result<Self>
pub fn with_inline_grl(self, grl_content: &str) -> Result<Self>
Add rules from inline GRL string.
Parses GRL rules directly from a string.
§Errors
Returns an error if the GRL syntax is invalid.
Sourcepub fn with_config(self, config: EngineConfig) -> Self
pub fn with_config(self, config: EngineConfig) -> Self
Set engine configuration.
Overrides the default engine configuration with custom settings.
Sourcepub fn build(self) -> RustRuleEngine
pub fn build(self) -> RustRuleEngine
Build the RustRuleEngine.
Consumes the builder and creates a configured rule engine instance.