Skip to main content

LogicEngine

Trait LogicEngine 

Source
pub trait LogicEngine {
    // Required methods
    fn id(&self) -> EngineId;
    fn paradigm(&self) -> Paradigm;
    fn name(&self) -> &'static str;
    fn can_handle(&self, node: &AstNode) -> bool;
    fn evaluate(
        &self,
        node: &AstNode,
        ctx: &EvalContext<'_>,
    ) -> Result<Verdict, EngineError>;
}
Expand description

The core trait every logic engine must implement.

Implementations are stateless by design — all state lives in EvalContext. This makes engines safe to share across threads and suitable for ROM.

Required Methods§

Source

fn id(&self) -> EngineId

Stable identifier for this engine instance.

Source

fn paradigm(&self) -> Paradigm

Which paradigm this engine primarily implements.

Source

fn name(&self) -> &'static str

Human-readable name for logic traces.

Source

fn can_handle(&self, node: &AstNode) -> bool

Whether this engine can handle the given AST node. Called by the router before evaluate to avoid wasted work.

Source

fn evaluate( &self, node: &AstNode, ctx: &EvalContext<'_>, ) -> Result<Verdict, EngineError>

Evaluate an AST node and return a Verdict.

Engines must be deterministic: same node + same ctx → same Verdict.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§