Skip to main content

TaskStore

Trait TaskStore 

Source
pub trait TaskStore: Send + Sync {
    // Required methods
    fn upsert<'life0, 'async_trait>(
        &'life0 self,
        stored: StoredTask,
    ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get<'life0, 'life1, 'async_trait>(
        &'life0 self,
        task_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<StoredTask>, StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn list<'life0, 'life1, 'async_trait>(
        &'life0 self,
        filter: &'life1 TaskFilter,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<StoredTask>, StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        task_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<bool, StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn compare_and_update<'life0, 'life1, 'async_trait>(
        &'life0 self,
        task_id: &'life1 str,
        update: StoredTask,
    ) -> Pin<Box<dyn Future<Output = Result<bool, StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Task persistence backend (P1-1).

The four operations mirror the A2A tasks/* surface: create/update (upsert), read (get), enumerate (list) and remove (delete). Implementations must be cheap under concurrent access; the server does not hold the returned snapshot across .await boundaries.

Required Methods§

Source

fn upsert<'life0, 'async_trait>( &'life0 self, stored: StoredTask, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Insert a new task or replace an existing one.

Source

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

Fetch a task snapshot by id, or None if absent.

Source

fn list<'life0, 'life1, 'async_trait>( &'life0 self, filter: &'life1 TaskFilter, ) -> Pin<Box<dyn Future<Output = Result<Vec<StoredTask>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List task snapshots matching filter, ordered by creation (oldest first).

Source

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

Delete a task by id. Returns true if a task was actually removed.

Provided Methods§

Source

fn compare_and_update<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, update: StoredTask, ) -> Pin<Box<dyn Future<Output = Result<bool, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Atomically replace the stored task for task_id when the currently stored status may transition to the update’s status (per TaskStatus::can_transition_to). Returns true when the update was applied.

0.22.0 audit fix: this closes the check-then-act window where a handler read a task, validated its status, and wrote it back — a concurrent writer (e.g. tasks/cancel racing the chain completing) could overwrite the other’s terminal state in between. The default implementation is a racy get + upsert fallback; backends that can should override it with a truly atomic operation.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§