Skip to main content

TaskStore

Trait TaskStore 

Source
pub trait TaskStore: Send + Sync {
    // Required methods
    fn save<'life0, 'life1, 'async_trait>(
        &'life0 self,
        task: &'life1 Task,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn load<'life0, 'async_trait>(
        &'life0 self,
        id: TaskId,
    ) -> Pin<Box<dyn Future<Output = Result<Task>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn list<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Task>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn delete<'life0, 'async_trait>(
        &'life0 self,
        id: TaskId,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn update<'life0, 'async_trait>(
        &'life0 self,
        id: TaskId,
        update: TaskUpdate,
    ) -> Pin<Box<dyn Future<Output = Result<Task>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Persistence interface for tasks.

Implementations must make TaskStore::update atomic with respect to concurrent writers, including other processes sharing the same state directory.

Required Methods§

Source

fn save<'life0, 'life1, 'async_trait>( &'life0 self, task: &'life1 Task, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Inserts or replaces the stored task.

Source

fn load<'life0, 'async_trait>( &'life0 self, id: TaskId, ) -> Pin<Box<dyn Future<Output = Result<Task>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Loads a task by id, or fails with Error::TaskNotFound when absent.

Source

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

Returns all stored tasks ordered by creation time.

Source

fn delete<'life0, 'async_trait>( &'life0 self, id: TaskId, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Deletes a task. Deleting a task that does not exist is not an error.

Source

fn update<'life0, 'async_trait>( &'life0 self, id: TaskId, update: TaskUpdate, ) -> Pin<Box<dyn Future<Output = Result<Task>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Applies update to the stored task under a lock and returns the saved result.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§