GRLQuery

Struct GRLQuery 

Source
pub struct GRLQuery {
    pub name: String,
    pub goal: String,
    pub strategy: GRLSearchStrategy,
    pub max_depth: usize,
    pub max_solutions: usize,
    pub enable_memoization: bool,
    pub on_success: Option<QueryAction>,
    pub on_failure: Option<QueryAction>,
    pub on_missing: Option<QueryAction>,
    pub params: HashMap<String, String>,
    pub when_condition: Option<String>,
}
Expand description

A GRL Query definition

Fields§

§name: String

Query name

§goal: String

Goal pattern to prove (as string expression)

§strategy: GRLSearchStrategy

Search strategy

§max_depth: usize

Maximum search depth

§max_solutions: usize

Maximum number of solutions

§enable_memoization: bool

Enable memoization

§on_success: Option<QueryAction>

Action on success

§on_failure: Option<QueryAction>

Action on failure

§on_missing: Option<QueryAction>

Action on missing facts

§params: HashMap<String, String>

Parameters for parameterized queries

§when_condition: Option<String>

Conditional execution (as string condition)

Implementations§

Source§

impl GRLQuery

Source

pub fn new(name: String, goal: String) -> Self

Create a new query with defaults

Source

pub fn with_strategy(self, strategy: GRLSearchStrategy) -> Self

Set search strategy

Source

pub fn with_max_depth(self, max_depth: usize) -> Self

Set max depth

Source

pub fn with_max_solutions(self, max_solutions: usize) -> Self

Set max solutions

Source

pub fn with_memoization(self, enable: bool) -> Self

Set memoization

Source

pub fn with_on_success(self, action: QueryAction) -> Self

Add success action

Source

pub fn with_on_failure(self, action: QueryAction) -> Self

Add failure action

Source

pub fn with_on_missing(self, action: QueryAction) -> Self

Add missing facts action

Source

pub fn with_param(self, name: String, type_name: String) -> Self

Add parameter

Source

pub fn with_when(self, condition: String) -> Self

Set conditional execution

Source

pub fn should_execute(&self, _facts: &Facts) -> Result<bool, RuleEngineError>

Check if query should execute based on when condition

Source

pub fn execute_success_actions( &self, facts: &mut Facts, ) -> Result<(), RuleEngineError>

Execute success actions

Source

pub fn execute_failure_actions( &self, facts: &mut Facts, ) -> Result<(), RuleEngineError>

Execute failure actions

Source

pub fn execute_missing_actions( &self, facts: &mut Facts, ) -> Result<(), RuleEngineError>

Execute missing facts actions

Source

pub fn to_config(&self) -> BackwardConfig

Convert to BackwardConfig

Trait Implementations§

Source§

impl Clone for GRLQuery

Source§

fn clone(&self) -> GRLQuery

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GRLQuery

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.