Skip to main content

ToolContext

Struct ToolContext 

Source
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>

Source

pub fn new(sandbox: &'a dyn SandboxPolicy) -> Self

Create a context with only sandbox (for tests or standalone use).

Source

pub fn with_child_ctx(self, ctx: &'a dyn ChildContext) -> Self

Attach a child context (builder pattern).

Source

pub fn sandbox(&self) -> &dyn SandboxPolicy

Sandbox policy for file path validation.

Source

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§

Source§

impl Debug for ToolContext<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.