Skip to main content

DownloadSource

Trait DownloadSource 

Source
pub trait DownloadSource: Send + Sync {
    // Required methods
    fn can_handle(&self, directive: &DownloadDirective) -> bool;
    fn resolve(
        &self,
        directive: &DownloadDirective,
    ) -> impl Future<Output = SourceResult<DownloadHandle>> + Send;
    fn download_with_progress(
        &self,
        handle: DownloadHandle,
        dest: &Path,
        progress: ProgressCallback,
    ) -> impl Future<Output = SourceResult<VerifiedFile>> + Send;

    // Provided method
    fn download(
        &self,
        handle: DownloadHandle,
        dest: &Path,
    ) -> impl Future<Output = SourceResult<VerifiedFile>> + Send { ... }
}
Expand description

Trait for download source implementations.

Each source (Nexus, GitHub, Google Drive, Mega, Direct URL) implements this trait. AnySource provides zero-cost enum dispatch, while this trait enables impl DownloadSource generics for monomorphization in hot paths.

Required Methods§

Source

fn can_handle(&self, directive: &DownloadDirective) -> bool

Check if this source can handle the given directive.

Source

fn resolve( &self, directive: &DownloadDirective, ) -> impl Future<Output = SourceResult<DownloadHandle>> + Send

Resolve a directive into a download handle with a concrete URL.

Source

fn download_with_progress( &self, handle: DownloadHandle, dest: &Path, progress: ProgressCallback, ) -> impl Future<Output = SourceResult<VerifiedFile>> + Send

Download the file to dest with progress reporting and verify its hash.

Provided Methods§

Source

fn download( &self, handle: DownloadHandle, dest: &Path, ) -> impl Future<Output = SourceResult<VerifiedFile>> + Send

Download the file to dest and verify its hash (no-op progress).

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§