pub struct DownloadWorker {
client: Client,
max_retries: u32,
}Expand description
Download worker that handles individual download tasks
Fields§
§client: ClientHTTP client for downloads
max_retries: u32Maximum retry attempts
Implementations§
Source§impl DownloadWorker
impl DownloadWorker
pub fn new() -> Self
Sourcepub async fn download<F>(
&self,
task: &DownloadTask,
stop: &AtomicBool,
on_progress: F,
) -> Result<DownloadResult, DownloadError>
pub async fn download<F>( &self, task: &DownloadTask, stop: &AtomicBool, on_progress: F, ) -> Result<DownloadResult, DownloadError>
Download a file with retry logic and progress tracking.
stop is the pause/cancel flag (see crate::download::stop). It is
checked between chunks and again between retries, so a paused download
stops promptly rather than after its next backoff — up to 45 seconds
away, which reads as the pause having done nothing.
TRACES: UR-055 | DR-168
Sourceasync fn try_download<F>(
&self,
task: &DownloadTask,
stop: &AtomicBool,
on_progress: &F,
) -> Result<DownloadResult, DownloadError>
async fn try_download<F>( &self, task: &DownloadTask, stop: &AtomicBool, on_progress: &F, ) -> Result<DownloadResult, DownloadError>
Attempt a single download
Sourcefn exponential_backoff(retry_count: u32) -> Duration
fn exponential_backoff(retry_count: u32) -> Duration
Calculate exponential backoff delay
Auto Trait Implementations§
impl Freeze for DownloadWorker
impl !RefUnwindSafe for DownloadWorker
impl Send for DownloadWorker
impl Sync for DownloadWorker
impl Unpin for DownloadWorker
impl UnsafeUnpin for DownloadWorker
impl !UnwindSafe for DownloadWorker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more