Struct ToolExecutionContext
pub struct ToolExecutionContext { /* private fields */ }Expand description
Per-call execution inputs supplied by the turn owner.
The token is a handle to the owner’s cancellation state. Spawned tasks do not inherit the task-local scope; capture the context or a child token before spawning work that should stop with the call.
Implementations§
Source§impl ToolExecutionContext
impl ToolExecutionContext
pub fn new(cancellation_token: Option<CancellationToken>) -> Self
pub fn cancellation_token(&self) -> Option<&CancellationToken>
Sourcepub fn current() -> Option<Self>
pub fn current() -> Option<Self>
Context for the future currently being polled, if it has a scope.
Sourcepub async fn run<T>(&self, future: impl Future<Output = Result<T>>) -> Result<T>
pub async fn run<T>(&self, future: impl Future<Output = Result<T>>) -> Result<T>
Scope the future and drop it when the token is cancelled.
An empty context masks any outer token. Cancellation wins when both branches are ready, and a pre-cancelled token never polls the future. Dropping a future does not undo side effects or await child cleanup.
Trait Implementations§
Source§impl Clone for ToolExecutionContext
impl Clone for ToolExecutionContext
Source§fn clone(&self) -> ToolExecutionContext
fn clone(&self) -> ToolExecutionContext
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · §fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ToolExecutionContext
impl Debug for ToolExecutionContext
Source§impl Default for ToolExecutionContext
impl Default for ToolExecutionContext
Source§fn default() -> ToolExecutionContext
fn default() -> ToolExecutionContext
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ToolExecutionContext
impl RefUnwindSafe for ToolExecutionContext
impl Send for ToolExecutionContext
impl Sync for ToolExecutionContext
impl Unpin for ToolExecutionContext
impl UnsafeUnpin for ToolExecutionContext
impl UnwindSafe for ToolExecutionContext
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