pub struct TaskStore { /* private fields */ }Expand description
Thread-safe task storage
Implementations§
Source§impl TaskStore
impl TaskStore
Sourcepub fn create_task(
&self,
tool_name: &str,
arguments: Value,
ttl: Option<u64>,
) -> (String, CancellationToken)
pub fn create_task( &self, tool_name: &str, arguments: Value, ttl: Option<u64>, ) -> (String, CancellationToken)
Create and store a new task
Returns the task ID and a cancellation token for the spawned work.
Sourcepub fn get_task(&self, task_id: &str) -> Option<TaskObject>
pub fn get_task(&self, task_id: &str) -> Option<TaskObject>
Get task object by ID
Sourcepub fn get_task_result(
&self,
task_id: &str,
) -> Option<(TaskObject, Option<CallToolResult>, Option<String>)>
pub fn get_task_result( &self, task_id: &str, ) -> Option<(TaskObject, Option<CallToolResult>, Option<String>)>
Get full task result by ID (task object, result, error)
Sourcepub async fn wait_for_completion(
&self,
task_id: &str,
) -> Option<(TaskObject, Option<CallToolResult>, Option<String>)>
pub async fn wait_for_completion( &self, task_id: &str, ) -> Option<(TaskObject, Option<CallToolResult>, Option<String>)>
Wait for a task to reach a terminal state, then return its result.
If the task is already terminal, returns immediately. Otherwise blocks until the task completes, fails, or is cancelled.
Sourcepub fn list_tasks(&self, status_filter: Option<TaskStatus>) -> Vec<TaskObject>
pub fn list_tasks(&self, status_filter: Option<TaskStatus>) -> Vec<TaskObject>
List all tasks, optionally filtered by status
Sourcepub fn require_input(&self, task_id: &str, message: &str) -> bool
pub fn require_input(&self, task_id: &str, message: &str) -> bool
Mark a task as requiring input
Sourcepub fn complete_task(&self, task_id: &str, result: CallToolResult) -> bool
pub fn complete_task(&self, task_id: &str, result: CallToolResult) -> bool
Mark a task as completed with a result
Sourcepub fn fail_task(&self, task_id: &str, error: &str) -> bool
pub fn fail_task(&self, task_id: &str, error: &str) -> bool
Mark a task as failed with an error
Sourcepub fn cancel_task(
&self,
task_id: &str,
reason: Option<&str>,
) -> Option<TaskObject>
pub fn cancel_task( &self, task_id: &str, reason: Option<&str>, ) -> Option<TaskObject>
Cancel a task
Sourcepub fn cleanup_expired(&self) -> usize
pub fn cleanup_expired(&self) -> usize
Remove expired tasks (call periodically for cleanup)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TaskStore
impl RefUnwindSafe for TaskStore
impl Send for TaskStore
impl Sync for TaskStore
impl Unpin for TaskStore
impl UnsafeUnpin for TaskStore
impl UnwindSafe for TaskStore
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