Skip to main content

RuleEngineBuilder

Struct RuleEngineBuilder 

Source
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

Source

pub fn new() -> Self

Create a new RuleEngineBuilder with default configuration.

Creates an empty knowledge base named “DefaultKB” and default engine configuration.

Source

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.

Source

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.

Source

pub fn with_config(self, config: EngineConfig) -> Self

Set engine configuration.

Overrides the default engine configuration with custom settings.

Source

pub fn build(self) -> RustRuleEngine

Build the RustRuleEngine.

Consumes the builder and creates a configured rule engine instance.

Trait Implementations§

Source§

impl Default for RuleEngineBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.