pub struct ToolContext<'a> { /* private fields */ }Expand description
Execution context provided to RustTool::execute.
Created by the dispatcher before calling a tool. Provides:
- Sandbox: path validation for file I/O
- ChildContext (optional): runtime interaction (command permissions, output emission, etc.)
§Lifetime
Borrows from the dispatcher’s lock scope. Tools must not
store references beyond execute().
Implementations§
Source§impl<'a> ToolContext<'a>
impl<'a> ToolContext<'a>
Sourcepub fn new(sandbox: &'a dyn SandboxPolicy) -> Self
pub fn new(sandbox: &'a dyn SandboxPolicy) -> Self
Create a context with only sandbox (for tests or standalone use).
Sourcepub fn with_child_ctx(self, ctx: &'a dyn ChildContext) -> Self
pub fn with_child_ctx(self, ctx: &'a dyn ChildContext) -> Self
Attach a child context (builder pattern).
Sourcepub fn sandbox(&self) -> &dyn SandboxPolicy
pub fn sandbox(&self) -> &dyn SandboxPolicy
Sandbox policy for file path validation.
Sourcepub fn child_ctx(&self) -> Option<&dyn ChildContext>
pub fn child_ctx(&self) -> Option<&dyn ChildContext>
Optional child context for runtime interaction.
Available when running inside a Component’s execution context.
None in standalone or test scenarios.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for ToolContext<'a>
impl<'a> !RefUnwindSafe for ToolContext<'a>
impl<'a> Send for ToolContext<'a>
impl<'a> Sync for ToolContext<'a>
impl<'a> Unpin for ToolContext<'a>
impl<'a> UnsafeUnpin for ToolContext<'a>
impl<'a> !UnwindSafe for ToolContext<'a>
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