EvaluationContext

Struct EvaluationContext 

Source
pub struct EvaluationContext<'a> {
    pub current_doc: &'a LemmaDoc,
    pub all_documents: &'a HashMap<String, LemmaDoc>,
    pub sources: &'a HashMap<String, String>,
    pub facts: HashMap<FactReference, LiteralValue>,
    pub timeout_tracker: &'a TimeoutTracker,
    pub limits: &'a ResourceLimits,
    pub rule_results: HashMap<RulePath, OperationResult>,
    pub operations: Vec<OperationRecord>,
}
Expand description

Context for evaluating a Lemma document

Contains all state needed for a single evaluation:

  • Facts (inputs)
  • Rule results (computed values)
  • Operation records (execution log)
  • Timeout tracking

Fields§

§current_doc: &'a LemmaDoc

Document being evaluated

§all_documents: &'a HashMap<String, LemmaDoc>

All loaded documents (needed when facts reference other documents)

§sources: &'a HashMap<String, String>

Source text for all documents (for error reporting) Maps source_id -> source text

§facts: HashMap<FactReference, LiteralValue>

Fact values (from document + overrides) Maps fact path -> concrete value Only contains facts that have actual values (not TypeAnnotations)

§timeout_tracker: &'a TimeoutTracker

Timeout tracker (platform-specific)

§limits: &'a ResourceLimits

Resource limits including timeout

§rule_results: HashMap<RulePath, OperationResult>

Rule results computed so far (populated during execution) Maps RulePath -> operation result (either Value or Veto)

§operations: Vec<OperationRecord>

Operation records - records every operation

Implementations§

Source§

impl<'a> EvaluationContext<'a>

Source

pub fn new( current_doc: &'a LemmaDoc, all_documents: &'a HashMap<String, LemmaDoc>, sources: &'a HashMap<String, String>, facts: HashMap<FactReference, LiteralValue>, timeout_tracker: &'a TimeoutTracker, limits: &'a ResourceLimits, ) -> Self

Create a new evaluation context

Source

pub fn check_timeout(&self) -> Result<(), LemmaError>

Check if evaluation has exceeded timeout

Auto Trait Implementations§

§

impl<'a> Freeze for EvaluationContext<'a>

§

impl<'a> RefUnwindSafe for EvaluationContext<'a>

§

impl<'a> Send for EvaluationContext<'a>

§

impl<'a> Sync for EvaluationContext<'a>

§

impl<'a> Unpin for EvaluationContext<'a>

§

impl<'a> UnwindSafe for EvaluationContext<'a>

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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.