DownloadStateRepositoryPort

Trait DownloadStateRepositoryPort 

Source
pub trait DownloadStateRepositoryPort: Send + Sync {
    // Required methods
    fn enqueue<'life0, 'life1, 'async_trait>(
        &'life0 self,
        download: &'life1 QueuedDownload,
    ) -> Pin<Box<dyn Future<Output = Result<(), RepositoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn update_status<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 DownloadId,
        status: DownloadStatus,
    ) -> Pin<Box<dyn Future<Output = Result<(), RepositoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn load_queue<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<QueuedDownload>, RepositoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn mark_failed<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        id: &'life1 DownloadId,
        error_message: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), RepositoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn remove<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 DownloadId,
    ) -> Pin<Box<dyn Future<Output = Result<(), RepositoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn prune_completed<'life0, 'async_trait>(
        &'life0 self,
        older_than_days: u32,
    ) -> Pin<Box<dyn Future<Output = Result<u32, RepositoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Port for persisting download queue state.

This trait is implemented by gglib-db and injected into the download manager to provide durable queue storage.

§Persistence Scope

Persisted:

  • Queued downloads (survive restarts)
  • Terminal results (completed/failed with enough info for history)
  • Retry counts (if retries are supported)

In-memory only:

  • Fine-grained progress (bytes, speed)
  • Active progress snapshots (broadcast via events)

§Usage

let repo: Arc<dyn DownloadStateRepositoryPort> = /* ... */;
repo.enqueue(&queued_download).await?;
let queue = repo.load_queue().await?;

Required Methods§

Source

fn enqueue<'life0, 'life1, 'async_trait>( &'life0 self, download: &'life1 QueuedDownload, ) -> Pin<Box<dyn Future<Output = Result<(), RepositoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Add a download to the persistent queue.

The download should be in Queued status when enqueued.

Source

fn update_status<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 DownloadId, status: DownloadStatus, ) -> Pin<Box<dyn Future<Output = Result<(), RepositoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Update the status of an existing download.

This is used to transition downloads through their lifecycle: Queued -> Downloading -> Completed/Failed/Cancelled

Source

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

Load all queued downloads from persistent storage.

Returns downloads that were queued but not yet completed. Used on application startup to restore the queue.

Source

fn mark_failed<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, id: &'life1 DownloadId, error_message: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<(), RepositoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Mark a download as failed with an error message.

This records the failure for history/retry purposes.

Source

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

Remove a download from the persistent queue.

Used when a download is cancelled or cleaned up.

Source

fn prune_completed<'life0, 'async_trait>( &'life0 self, older_than_days: u32, ) -> Pin<Box<dyn Future<Output = Result<u32, RepositoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Prune completed/failed downloads older than the given age.

This is optional cleanup to prevent unbounded growth.

Implementors§