pub struct Engine { /* private fields */ }Expand description
Engine for evaluating Lemma rules
Pure Rust implementation that evaluates Lemma docs directly from the AST.
Implementations§
Source§impl Engine
impl Engine
pub fn new() -> Self
Sourcepub fn with_limits(limits: ResourceLimits) -> Self
pub fn with_limits(limits: ResourceLimits) -> Self
Create an engine with custom resource limits
Sourcepub fn limits(&self) -> &ResourceLimits
pub fn limits(&self) -> &ResourceLimits
Get the current resource limits
pub fn add_lemma_code( &mut self, lemma_code: &str, source: &str, ) -> LemmaResult<()>
pub fn remove_document(&mut self, doc_name: &str)
pub fn list_documents(&self) -> Vec<String>
pub fn get_document(&self, doc_name: &str) -> Option<&LemmaDoc>
pub fn get_document_facts(&self, doc_name: &str) -> Vec<&LemmaFact>
pub fn get_document_rules(&self, doc_name: &str) -> Vec<&LemmaRule>
Sourcepub fn evaluate(
&self,
doc_name: &str,
rule_names: Option<Vec<String>>,
fact_overrides: Option<Vec<LemmaFact>>,
) -> LemmaResult<Response>
pub fn evaluate( &self, doc_name: &str, rule_names: Option<Vec<String>>, fact_overrides: Option<Vec<LemmaFact>>, ) -> LemmaResult<Response>
Evaluate rules in a document with optional fact overrides
If rule_names is None, evaluates all rules.
If rule_names is Some, only returns results for the specified rules,
but still computes their dependencies.
Fact overrides must be pre-parsed using parse_facts().
Sourcepub fn get_all_documents(&self) -> &HashMap<String, LemmaDoc>
pub fn get_all_documents(&self) -> &HashMap<String, LemmaDoc>
Get all documents (needed by serializers for schema resolution)
Sourcepub fn invert(
&self,
document: &str,
rule: &str,
target: Target,
given_facts: HashMap<String, LiteralValue>,
) -> LemmaResult<Vec<HashMap<FactReference, Domain>>>
pub fn invert( &self, document: &str, rule: &str, target: Target, given_facts: HashMap<String, LiteralValue>, ) -> LemmaResult<Vec<HashMap<FactReference, Domain>>>
Invert a rule to find input domains that produce a desired outcome
Returns a vector of solutions, where each solution is a map from fact paths to their valid domains. Multiple solutions represent different ways to satisfy the target outcome (disjunction).
Use given_facts to constrain the search to specific known values.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Engine
impl RefUnwindSafe for Engine
impl Send for Engine
impl Sync for Engine
impl Unpin for Engine
impl UnwindSafe for Engine
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> 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