Skip to main content

Module events

Module events 

Source
Expand description

Event types emitted by [DownloadBuilder::spawn].

The channel-based API lets callers react to progress without dealing with closure lifetimes or shared mutable state.

§Example

use kget::{builder, DownloadEvent};

let (handle, events) = kget::builder("https://example.com/file.zip").spawn();

for event in events {
    match event {
        DownloadEvent::Progress { percent, speed_bps, .. } =>
            println!("{:.1}%  ({} B/s)", percent, speed_bps),
        DownloadEvent::Completed { path, .. } =>
            println!("Saved to {path}"),
        DownloadEvent::Error(msg) =>
            eprintln!("Failed: {msg}"),
        _ => {}
    }
}

handle.join().unwrap().unwrap();

Enums§

DownloadEvent
An event emitted by an in-progress download.