Skip to main content

TaskStore

Trait TaskStore 

Source
pub trait TaskStore: Send + Sync {
    // Required methods
    fn create_task<'life0, 'async_trait>(
        &'life0 self,
        entry: TaskStoreEntry,
    ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn get_task<'life0, 'life1, 'async_trait>(
        &'life0 self,
        task_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<TaskStoreEntry, A2aError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn update_status<'life0, 'life1, 'async_trait>(
        &'life0 self,
        task_id: &'life1 str,
        status: TaskStatus,
    ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn add_artifact<'life0, 'life1, 'async_trait>(
        &'life0 self,
        task_id: &'life1 str,
        artifact: Artifact,
    ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn add_history_message<'life0, 'life1, 'async_trait>(
        &'life0 self,
        task_id: &'life1 str,
        message: Message,
    ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn find_task_by_context<'life0, 'life1, 'async_trait>(
        &'life0 self,
        context_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<TaskStoreEntry>, A2aError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn list_tasks<'life0, 'async_trait>(
        &'life0 self,
        params: ListTasksParams,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<TaskStoreEntry>, A2aError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn delete_task<'life0, 'life1, 'async_trait>(
        &'life0 self,
        task_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
}
Available on crate features server and a2a-v1 only.
Expand description

Async trait for persisting A2A task state.

Implementations must be Send + Sync for use across async boundaries.

Required Methods§

Source

fn create_task<'life0, 'async_trait>( &'life0 self, entry: TaskStoreEntry, ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Persists a new task entry.

Source

fn get_task<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<TaskStoreEntry, A2aError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Retrieves a task by ID.

§Errors

Returns A2aError::TaskNotFound if the task does not exist.

Source

fn update_status<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, status: TaskStatus, ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Updates the status of an existing task.

§Errors

Returns A2aError::TaskNotFound if the task does not exist.

Source

fn add_artifact<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, artifact: Artifact, ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Appends an artifact to an existing task.

§Errors

Returns A2aError::TaskNotFound if the task does not exist.

Source

fn add_history_message<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, message: Message, ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Appends a message to the task’s history.

§Errors

Returns A2aError::TaskNotFound if the task does not exist.

Source

fn find_task_by_context<'life0, 'life1, 'async_trait>( &'life0 self, context_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<TaskStoreEntry>, A2aError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Finds the most recently updated non-terminal task for a given contextId. Returns None if no non-terminal task exists for the context.

Source

fn list_tasks<'life0, 'async_trait>( &'life0 self, params: ListTasksParams, ) -> Pin<Box<dyn Future<Output = Result<Vec<TaskStoreEntry>, A2aError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Lists tasks matching the given parameters.

Source

fn delete_task<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Deletes a task by ID.

§Errors

Returns A2aError::TaskNotFound if the task does not exist.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§