ContextLike

Trait ContextLike 

Source
pub trait ContextLike {
    // Required methods
    fn start_closure(&mut self) -> [(Arc<str>, Arc<Value>); 2];
    fn set_key(&mut self, index: usize, identifier: Arc<str>);
    fn set_parameter(&mut self, index: usize, value: Arc<Value>);
    fn end_closure(&mut self, stack: [(Arc<str>, Arc<Value>); 2]);
    fn get_value(&mut self, reference: &Reference) -> Result<Arc<Value>>;
    fn set_value(&mut self, identifier: &str, value: Arc<Value>) -> Result<()>;
    fn function_call(
        &mut self,
        name: Arc<str>,
        arg: Arc<Value>,
    ) -> Result<Arc<Value>>;
    fn method_call(
        &mut self,
        name: Arc<str>,
        value: Arc<Value>,
        arg: Arc<Value>,
    ) -> Result<Arc<Value>>;
    fn inference_call(
        &mut self,
        reference: Arc<Reference>,
        arg: Arc<Value>,
    ) -> Result<Arc<Value>>;
    fn run_evaluation(
        &mut self,
        start_state: Option<Arc<str>>,
    ) -> WorkflowStatus;
}
Expand description

Evaluation context interface used by the AIMX engine.

Implementors provide:

  • Reference lookup (get_value / set_value).
  • Function and method dispatch via FunctionRegistry.
  • Closure parameter stack management.
  • Inference calls into workflows or closures.
  • Imperative workflow execution via ContextLike::run_evaluation.

Required Methods§

Source

fn start_closure(&mut self) -> [(Arc<str>, Arc<Value>); 2]

Start a new closure and save the current stack.

Source

fn set_key(&mut self, index: usize, identifier: Arc<str>)

Set the identifier of a closure parameter slot (0 or 1).

Source

fn set_parameter(&mut self, index: usize, value: Arc<Value>)

Set the value of the index mapped parameter used by element-wise functions like map.

§Arguments
  • index - The index value to set (0 or 1)
  • value - The value to set
Source

fn end_closure(&mut self, stack: [(Arc<str>, Arc<Value>); 2])

End the closure and restore the previous stack.

Source

fn get_value(&mut self, reference: &Reference) -> Result<Arc<Value>>

Get the value of a referenced rule or parameter variable.

§Arguments
  • reference - The reference to resolve
§Returns

Returns the value of the referenced variable or an error if the reference cannot be resolved.

Source

fn set_value(&mut self, identifier: &str, value: Arc<Value>) -> Result<()>

Set the value of a rule.

§Arguments
  • reference - The reference to the rule to set
  • value - The value to assign
§Returns

Returns Ok(()) on success or an error if the referenced rule cannot be set.

Source

fn function_call( &mut self, name: Arc<str>, arg: Arc<Value>, ) -> Result<Arc<Value>>

Call a standalone function.

§Arguments
  • name - The name of the function to call
  • arg - The argument(s) to pass to the function (Value can be Empty, Literal, or Array)
§Returns

Returns the result of the function call or an error if the function is not found or if there’s an error during execution.

Source

fn method_call( &mut self, name: Arc<str>, value: Arc<Value>, arg: Arc<Value>, ) -> Result<Arc<Value>>

Call a method on a value.

§Arguments
  • name - The name of the method to call
  • value - The value on which to call the method
  • arg - The argument(s) to pass to the method (Value can be Empty, Literal, or Array)
§Returns

Returns the result of the method call or an error if the method is not found or if there’s an error during execution.

Source

fn inference_call( &mut self, reference: Arc<Reference>, arg: Arc<Value>, ) -> Result<Arc<Value>>

Run inference on a referenced workflow.

§Arguments
  • reference - The workflow reference
  • arg - The argument(s) to pass to the inference call (Value can be Empty, Literal, or Array)
§Returns

Returns the result of the inference call or an error if the workflow is not found or if there’s an error during execution.

Source

fn run_evaluation(&mut self, start_state: Option<Arc<str>>) -> WorkflowStatus

Implementors§