pub struct ExecutionContext {
pub bindings: HashMap<String, ToolResult>,
pub execution_log: Vec<ExecutionStep>,
pub variables: Map<String, Value>,
pub last_result: Option<ToolResult>,
/* private fields */
}Expand description
Context for tool execution, carrying variables and state
Fields§
§bindings: HashMap<String, ToolResult>Variable bindings (for new DSL)
execution_log: Vec<ExecutionStep>Execution history for debugging
variables: Map<String, Value>Variables for old API compatibility
last_result: Option<ToolResult>Last result for old API compatibility
Implementations§
Source§impl ExecutionContext
impl ExecutionContext
Sourcepub fn nested_scope(&self) -> Self
pub fn nested_scope(&self) -> Self
Create a nested scope with this context as parent
Sourcepub fn set_variable(&mut self, key: impl Into<String>, value: Value)
pub fn set_variable(&mut self, key: impl Into<String>, value: Value)
Set a variable (old API)
Sourcepub fn get_variable(&self, key: &str) -> Option<&Value>
pub fn get_variable(&self, key: &str) -> Option<&Value>
Get a variable (old API)
Sourcepub fn with_variable(self, key: impl Into<String>, value: Value) -> Self
pub fn with_variable(self, key: impl Into<String>, value: Value) -> Self
With variable builder pattern (old API)
Sourcepub fn with_last_result(self, result: ToolResult) -> Self
pub fn with_last_result(self, result: ToolResult) -> Self
With last result (old API)
Sourcepub fn bind(&mut self, name: String, value: ToolResult)
pub fn bind(&mut self, name: String, value: ToolResult)
Bind a variable to a value
Sourcepub fn lookup(&self, name: &str) -> Option<&ToolResult>
pub fn lookup(&self, name: &str) -> Option<&ToolResult>
Look up a variable, checking parent scopes if not found locally
Sourcepub fn log_step(
&mut self,
step_type: String,
result: Result<ToolResult, ToolError>,
)
pub fn log_step( &mut self, step_type: String, result: Result<ToolResult, ToolError>, )
Log an execution step
Sourcepub fn all_bindings(&self) -> HashMap<String, &ToolResult>
pub fn all_bindings(&self) -> HashMap<String, &ToolResult>
Get all bindings including from parent scopes
Trait Implementations§
Source§impl Clone for ExecutionContext
impl Clone for ExecutionContext
Source§fn clone(&self) -> ExecutionContext
fn clone(&self) -> ExecutionContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ExecutionContext
impl Debug for ExecutionContext
Auto Trait Implementations§
impl Freeze for ExecutionContext
impl RefUnwindSafe for ExecutionContext
impl Send for ExecutionContext
impl Sync for ExecutionContext
impl Unpin for ExecutionContext
impl UnsafeUnpin for ExecutionContext
impl UnwindSafe for ExecutionContext
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
Mutably borrows from an owned value. Read more