pub trait DownloadManagerPort: Send + Sync {
Show 16 methods
// Required methods
fn queue_download<'life0, 'async_trait>(
&'life0 self,
request: DownloadRequest,
) -> Pin<Box<dyn Future<Output = Result<DownloadId, DownloadError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn queue_and_process<'async_trait>(
self: Arc<Self>,
request: DownloadRequest,
) -> Pin<Box<dyn Future<Output = Result<DownloadId, DownloadError>> + Send + 'async_trait>>
where Self: 'async_trait;
fn queue_smart<'async_trait>(
self: Arc<Self>,
repo_id: String,
quantization: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<(usize, usize), DownloadError>> + Send + 'async_trait>>
where Self: 'async_trait;
fn get_queue_snapshot<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<QueueSnapshot, DownloadError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn cancel_download<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 DownloadId,
) -> Pin<Box<dyn Future<Output = Result<(), DownloadError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn cancel_all<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), DownloadError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn has_download<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 DownloadId,
) -> Pin<Box<dyn Future<Output = Result<bool, DownloadError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn active_count<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u32, DownloadError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn pending_count<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u32, DownloadError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn remove_from_queue<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 DownloadId,
) -> Pin<Box<dyn Future<Output = Result<(), DownloadError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn reorder_queue<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 DownloadId,
new_position: u32,
) -> Pin<Box<dyn Future<Output = Result<u32, DownloadError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn cancel_group<'life0, 'life1, 'async_trait>(
&'life0 self,
group_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), DownloadError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn retry<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 DownloadId,
) -> Pin<Box<dyn Future<Output = Result<u32, DownloadError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn clear_failed<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), DownloadError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn set_max_queue_size<'life0, 'async_trait>(
&'life0 self,
size: u32,
) -> Pin<Box<dyn Future<Output = Result<(), DownloadError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_max_queue_size<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u32, DownloadError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Required Methods§
Sourcefn queue_download<'life0, 'async_trait>(
&'life0 self,
request: DownloadRequest,
) -> Pin<Box<dyn Future<Output = Result<DownloadId, DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn queue_download<'life0, 'async_trait>(
&'life0 self,
request: DownloadRequest,
) -> Pin<Box<dyn Future<Output = Result<DownloadId, DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Queue a new download.
Returns the download ID which can be used to track or cancel the download. The download will be processed according to the manager’s concurrency settings.
Sourcefn queue_and_process<'async_trait>(
self: Arc<Self>,
request: DownloadRequest,
) -> Pin<Box<dyn Future<Output = Result<DownloadId, DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
fn queue_and_process<'async_trait>(
self: Arc<Self>,
request: DownloadRequest,
) -> Pin<Box<dyn Future<Output = Result<DownloadId, DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
Queue a download and ensure the queue processor is running.
This is the recommended method for GUI adapters. It combines queuing with worker lifecycle management, hiding the internal details of how downloads are processed.
The self: Arc<Self> receiver allows implementations to clone the
Arc and spawn worker tasks. This is object-safe and works with
Arc<dyn DownloadManagerPort>.
Returns the download ID on success.
Sourcefn queue_smart<'async_trait>(
self: Arc<Self>,
repo_id: String,
quantization: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<(usize, usize), DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
fn queue_smart<'async_trait>(
self: Arc<Self>,
repo_id: String,
quantization: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<(usize, usize), DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
Queue a download with smart quantization selection.
This is the recommended method for GUI adapters when the quantization may be optional. It:
- Selects the best quantization if none specified
- Validates the requested quantization exists
- Queues the download and starts processing
§Quantization Selection Rules
- If a quantization is provided, validates it exists in the repository
- If none provided and 1 option exists, auto-picks it (pre-quantized model)
- If none provided and multiple exist, uses default preference order
- Returns error if requested quant not found or no suitable default
§Arguments
repo_id-HuggingFacerepository ID (e.g., “unsloth/Llama-3-GGUF”)quantization- Optional quantization name (e.g., “Q4_K_M”, “Q8_0”)
§Returns
Returns (position, shard_count) on success.
Sourcefn get_queue_snapshot<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<QueueSnapshot, DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_queue_snapshot<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<QueueSnapshot, DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get a snapshot of the current queue state.
Returns all queued, active, and recently completed/failed downloads. This is used by UIs to display download status.
Sourcefn cancel_download<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 DownloadId,
) -> Pin<Box<dyn Future<Output = Result<(), DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn cancel_download<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 DownloadId,
) -> Pin<Box<dyn Future<Output = Result<(), DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Cancel a download.
If the download is queued, it’s removed from the queue. If the download is active, the underlying process is terminated. Returns an error if the download ID is not found.
Sourcefn cancel_all<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn cancel_all<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Cancel all active and queued downloads.
This is used during application shutdown or when the user wants to clear the queue.
Sourcefn has_download<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 DownloadId,
) -> Pin<Box<dyn Future<Output = Result<bool, DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn has_download<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 DownloadId,
) -> Pin<Box<dyn Future<Output = Result<bool, DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Check if a download with the given ID exists in the queue.
Sourcefn active_count<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u32, DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn active_count<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u32, DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get the number of active downloads.
Sourcefn pending_count<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u32, DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn pending_count<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u32, DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get the number of pending (queued) downloads.
Sourcefn remove_from_queue<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 DownloadId,
) -> Pin<Box<dyn Future<Output = Result<(), DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn remove_from_queue<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 DownloadId,
) -> Pin<Box<dyn Future<Output = Result<(), DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Remove a pending download from the queue.
This is for items that haven’t started yet. For active downloads,
use cancel_download instead.
Sourcefn reorder_queue<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 DownloadId,
new_position: u32,
) -> Pin<Box<dyn Future<Output = Result<u32, DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn reorder_queue<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 DownloadId,
new_position: u32,
) -> Pin<Box<dyn Future<Output = Result<u32, DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Reorder a download to a new position in the queue.
The position is 1-based where 1 is next to run. Returns the actual position assigned (may differ if requested position is out of bounds).
Sourcefn cancel_group<'life0, 'life1, 'async_trait>(
&'life0 self,
group_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn cancel_group<'life0, 'life1, 'async_trait>(
&'life0 self,
group_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Cancel all downloads in a shard group.
Used for canceling multi-file model downloads where shards are
queued together. The group_id matches QueuedDownload.group_id.
Sourcefn retry<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 DownloadId,
) -> Pin<Box<dyn Future<Output = Result<u32, DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn retry<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 DownloadId,
) -> Pin<Box<dyn Future<Output = Result<u32, DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retry a failed download.
Moves the download from the failures list back to the queue. Returns the position in queue where it was added.
Sourcefn clear_failed<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn clear_failed<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Clear all failed downloads from the failures list.
Sourcefn set_max_queue_size<'life0, 'async_trait>(
&'life0 self,
size: u32,
) -> Pin<Box<dyn Future<Output = Result<(), DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn set_max_queue_size<'life0, 'async_trait>(
&'life0 self,
size: u32,
) -> Pin<Box<dyn Future<Output = Result<(), DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Update the maximum queue size.
Downloads already in queue are not affected, but new downloads may be rejected if the queue is at capacity.
Sourcefn get_max_queue_size<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u32, DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_max_queue_size<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u32, DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get the maximum queue size.