Skip to main content

DownloadOptions

Struct DownloadOptions 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional 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: u32

Total attempts including the first; values below 1 are treated as 1.

§retry_backoff: Duration

Delay before the first retry, doubled each time.

§root_certs: RootCerts

Trust anchors for HTTPS downloads; see RootCerts.

Implementations§

Source§

impl DownloadOptions

Source

pub fn with_connect_timeout(self, timeout: Duration) -> Self

Source

pub fn with_total_timeout(self, timeout: Duration) -> Self

Source

pub fn with_progress( self, progress: impl Fn(u64, u64) + Send + Sync + 'static, ) -> Self

Source

pub fn with_cancel(self, cancel: Arc<AtomicBool>) -> Self

Source

pub fn with_max_attempts(self, attempts: u32) -> Self

Source

pub fn with_retry_backoff(self, backoff: Duration) -> Self

Source

pub fn with_root_certs(self, root_certs: RootCerts) -> Self

Select the trust anchors for HTTPS downloads; see RootCerts.

Trait Implementations§

Source§

impl Clone for DownloadOptions

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DownloadOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DownloadOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for DownloadOptions

§

impl !UnwindSafe for DownloadOptions

§

impl Forget for DownloadOptions

§

impl Freeze for DownloadOptions
where *const ArcInner<dyn Fn(u64, u64) + Sync + Send> is !null: Freeze, PhantomData<ArcInner<dyn Fn(u64, u64) + Sync + Send>>: Freeze, *const ArcInner<Atomic<bool>> is !null: Freeze, PhantomData<ArcInner<Atomic<bool>>>: Freeze,

§

impl Move for DownloadOptions

§

impl Send for DownloadOptions
where Arc<dyn Fn(u64, u64) + Sync + Send>: Send, Arc<Atomic<bool>>: Send,

§

impl Sync for DownloadOptions
where Arc<dyn Fn(u64, u64) + Sync + Send>: Sync, Arc<Atomic<bool>>: Sync,

§

impl Unpin for DownloadOptions
where Arc<dyn Fn(u64, u64) + Sync + Send>: Unpin, Arc<Atomic<bool>>: Unpin,

§

impl UnsafeUnpin for DownloadOptions
where *const ArcInner<dyn Fn(u64, u64) + Sync + Send> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn Fn(u64, u64) + Sync + Send>>: UnsafeUnpin, *const ArcInner<Atomic<bool>> is !null: UnsafeUnpin, PhantomData<ArcInner<Atomic<bool>>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.