pub struct ExecutionPlan {
pub doc_name: String,
pub facts: HashMap<FactPath, FactData>,
pub rules: Vec<ExecutableRule>,
pub sources: HashMap<String, String>,
}Expand description
A complete execution plan ready for the evaluator
Contains the topologically sorted list of rules to execute, along with all facts. Self-contained structure - no document lookups required during evaluation.
Fields§
§doc_name: StringMain document name
facts: HashMap<FactPath, FactData>Per-fact data: value, type-only, or document reference (aligned with FactData).
rules: Vec<ExecutableRule>Rules to execute in topological order (sorted by dependencies)
sources: HashMap<String, String>Source code for error messages
Implementations§
Source§impl ExecutionPlan
impl ExecutionPlan
Sourcepub fn schema(&self) -> DocumentSchema
pub fn schema(&self) -> DocumentSchema
Build a DocumentSchema summarising all of this plan’s facts and
rules.
All facts with a typed schema (local and cross-document) are included. Document-reference facts (which have no schema type) are excluded. Only local rules (no cross-document segments) are included. Results are sorted alphabetically by name for deterministic output.
Sourcepub fn schema_for_rules(
&self,
rule_names: &[String],
) -> Result<DocumentSchema, LemmaError>
pub fn schema_for_rules( &self, rule_names: &[String], ) -> Result<DocumentSchema, LemmaError>
Build a DocumentSchema scoped to specific rules.
The returned schema contains only the facts needed by the given rules
(transitively, via needs_facts) and only those rules. This is the
“what do I need to evaluate these rules?” view.
Returns Err if any rule name is not found in the plan.
Sourcepub fn get_fact_path_by_str(&self, name: &str) -> Option<&FactPath>
pub fn get_fact_path_by_str(&self, name: &str) -> Option<&FactPath>
Look up a fact by its path string (e.g., “age” or “rules.base_price”).
Sourcepub fn get_rule(&self, name: &str) -> Option<&ExecutableRule>
pub fn get_rule(&self, name: &str) -> Option<&ExecutableRule>
Look up a local rule by its name (rule in the main document).
Sourcepub fn get_rule_by_path(&self, rule_path: &RulePath) -> Option<&ExecutableRule>
pub fn get_rule_by_path(&self, rule_path: &RulePath) -> Option<&ExecutableRule>
Look up a rule by its full path.
Sourcepub fn get_fact_value(&self, path: &FactPath) -> Option<&LiteralValue>
pub fn get_fact_value(&self, path: &FactPath) -> Option<&LiteralValue>
Get the literal value for a fact path, if it exists and has a literal value.
Sourcepub fn with_fact_values(
self,
values: HashMap<String, String>,
limits: &ResourceLimits,
) -> Result<Self, LemmaError>
pub fn with_fact_values( self, values: HashMap<String, String>, limits: &ResourceLimits, ) -> Result<Self, LemmaError>
Provide string values for facts.
Parses each string to its expected type, validates constraints, and applies to the plan.
Trait Implementations§
Source§impl Clone for ExecutionPlan
impl Clone for ExecutionPlan
Source§fn clone(&self) -> ExecutionPlan
fn clone(&self) -> ExecutionPlan
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ExecutionPlan
impl Debug for ExecutionPlan
Source§impl<'de> Deserialize<'de> for ExecutionPlan
impl<'de> Deserialize<'de> for ExecutionPlan
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for ExecutionPlan
impl RefUnwindSafe for ExecutionPlan
impl Send for ExecutionPlan
impl Sync for ExecutionPlan
impl Unpin for ExecutionPlan
impl UnsafeUnpin for ExecutionPlan
impl UnwindSafe for ExecutionPlan
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more