pub fn resume(
tmp_path: impl AsRef<Path>,
url: Option<Url>,
partial_config: PartialConfig,
tx: Tx,
token: CancellationToken,
)Expand description
Spawn a detached task that resumes a previously interrupted download from its
.part file.
This is the one-shot form of plan_resume followed by
DownloadPlan::start. url is optional. When Some, the resume resolves
and validates against that URL exactly as before. When None, the task
reuses the initial URL persisted in the .fd state file — the one the
original download recorded (the durable initial URL, not the transient
redirect/final_url). So a caller can resume purely from the .part path;
redirects are re-resolved through a fresh prefetch on every resume.
If the download cannot be continued — tmp_path is not a .part file, the
.fd state file is missing, the server does not support range requests, or
the remote file changed — the task emits
Event::ResumeError and stops without
falling back to a full re-download. If tmp_path itself does not exist, the
call falls back to a fresh download only when a url is available; with
url = None there is nothing to fetch, so it emits
ResumeError(StateError::NoUrl) instead. Likewise, when url = None but the
.fd carries no resolvable URL, the call reports StateError::NoUrl.
Completion is observed the same way as download: wait for the single
Event::Terminated, or drain the Rx until it disconnects.