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§
Sourcefn 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 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.
Sourcefn 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 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
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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,
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.