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§
Sourcefn can_handle(&self, directive: &DownloadDirective) -> bool
fn can_handle(&self, directive: &DownloadDirective) -> bool
Check if this source can handle the given directive.
Sourcefn resolve(
&self,
directive: &DownloadDirective,
) -> impl Future<Output = SourceResult<DownloadHandle>> + Send
fn resolve( &self, directive: &DownloadDirective, ) -> impl Future<Output = SourceResult<DownloadHandle>> + Send
Resolve a directive into a download handle with a concrete URL.
Sourcefn download_with_progress(
&self,
handle: DownloadHandle,
dest: &Path,
progress: ProgressCallback,
) -> impl Future<Output = SourceResult<VerifiedFile>> + Send
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§
Sourcefn download(
&self,
handle: DownloadHandle,
dest: &Path,
) -> impl Future<Output = SourceResult<VerifiedFile>> + Send
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".