engine_download: a type for a download's job
Some checks are pending
CI / check (push) Waiting to run
CI / windows-build (push) Waiting to run
CI / macos-build (push) Waiting to run

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
vrubelroman 2026-10-26 03:03:09 +03:00
parent 73593ddfc5
commit 04d337c106

View file

@ -138,6 +138,9 @@ pub enum Stage {
Cancelled,
}
/// What a download thread does: reports its stages, stops when told; the file in the end.
pub type Job = fn(&dyn Fn(Stage), &AtomicBool) -> Result<PathBuf, Failure>;
/// A download running in a background thread.
pub struct Download {
stage: Arc<Mutex<Stage>>,
@ -155,7 +158,7 @@ impl Download {
pub fn spawn(
ctx: &egui::Context,
total: u64,
job: fn(&dyn Fn(Stage), &AtomicBool) -> Result<PathBuf, Failure>,
job: Job,
) -> Download {
let stage = Arc::new(Mutex::new(Stage::Downloading { done: 0, total }));
let cancel = Arc::new(AtomicBool::new(false));