#[non_exhaustive]pub struct DownloadOptions {
pub connect_timeout: Duration,
pub total_timeout: Duration,
pub progress: Option<ProgressCallback>,
pub cancel: Option<Arc<AtomicBool>>,
pub max_attempts: u32,
pub retry_backoff: Duration,
pub root_certs: RootCerts,
}Expand description
How a component archive is downloaded.
Default reproduces the historical behaviour: 10 s connect timeout, 300 s total timeout,
no progress callback, no cancellation, and up to 3 attempts on transient failures.
Build one with the with_* methods:
use alef_component_runtime::DownloadOptions;
use std::time::Duration;
let options = DownloadOptions::default()
.with_total_timeout(Duration::from_secs(900))
.with_progress(|downloaded, total| eprintln!("{downloaded}/{total}"));Retries apply to connect errors, timeouts, interrupted body reads and HTTP 408/429/5xx.
HTTP 4xx responses and integrity failures (size, digest, signature) are never retried.
progress and cancel also apply to file:// sources and
ArtifactCache::install_from_reader.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.connect_timeout: Duration§total_timeout: Duration§progress: Option<ProgressCallback>§cancel: Option<Arc<AtomicBool>>Set to true from any thread to abort; checked between chunks and between retries.
An aborted install returns ComponentError::Cancelled.
max_attempts: u32Total attempts including the first; values below 1 are treated as 1.
retry_backoff: DurationDelay before the first retry, doubled each time.
root_certs: RootCertsTrust anchors for HTTPS downloads; see RootCerts.
Implementations§
Source§impl DownloadOptions
impl DownloadOptions
pub fn with_connect_timeout(self, timeout: Duration) -> Self
pub fn with_total_timeout(self, timeout: Duration) -> Self
pub fn with_progress( self, progress: impl Fn(u64, u64) + Send + Sync + 'static, ) -> Self
pub fn with_cancel(self, cancel: Arc<AtomicBool>) -> Self
pub fn with_max_attempts(self, attempts: u32) -> Self
pub fn with_retry_backoff(self, backoff: Duration) -> Self
Sourcepub fn with_root_certs(self, root_certs: RootCerts) -> Self
pub fn with_root_certs(self, root_certs: RootCerts) -> Self
Select the trust anchors for HTTPS downloads; see RootCerts.