pub struct SubtaskHandle<T: Send + 'static> {
pub thread_id: ThreadId,
/* private fields */
}Expand description
Handle to a running subtask. Allows joining, cancelling, and updating status.
The type parameter T is the return type of the async function.
For subagents that return string results, use SubtaskHandle<String>.
Fields§
§thread_id: ThreadIdThe thread ID in the ThreadManager.
Implementations§
Source§impl<T: Send + 'static> SubtaskHandle<T>
impl<T: Send + 'static> SubtaskHandle<T>
Sourcepub async fn join(self) -> Result<T, String>
pub async fn join(self) -> Result<T, String>
Wait for the subtask to complete and return its result.
This consumes the handle. After joining, the thread status is updated to Completed or Failed.
Sourcepub fn cancel(&self)
pub fn cancel(&self)
Cancel the subtask.
This signals the cancellation token. The subtask’s async function
should check token.is_cancelled() or use token.cancelled().await.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Check if the subtask has been cancelled.
Sourcepub async fn set_description(&self, description: impl Into<String>)
pub async fn set_description(&self, description: impl Into<String>)
Update the description shown in the sidebar for this subtask.
Sourcepub async fn set_status(&self, status: ThreadStatus)
pub async fn set_status(&self, status: ThreadStatus)
Update the status of the subtask’s thread.
Sourcepub fn cancel_token(&self) -> CancellationToken
pub fn cancel_token(&self) -> CancellationToken
Get the cancellation token (for passing to subtask internals).
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for SubtaskHandle<T>
impl<T> !RefUnwindSafe for SubtaskHandle<T>
impl<T> Send for SubtaskHandle<T>
impl<T> Sync for SubtaskHandle<T>
impl<T> Unpin for SubtaskHandle<T>
impl<T> UnsafeUnpin for SubtaskHandle<T>
impl<T> !UnwindSafe for SubtaskHandle<T>
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