gglib_core/events/
download.rs1use super::AppEvent;
4use crate::download::DownloadEvent;
5
6impl AppEvent {
7 pub fn download_started(id: impl Into<String>, _display_name: impl Into<String>) -> Self {
9 Self::Download {
10 event: DownloadEvent::started(id),
11 }
12 }
13
14 pub fn download_progress(
20 id: impl Into<String>,
21 downloaded: u64,
22 total: u64,
23 speed_bps: Option<f64>,
24 eta_seconds: Option<f64>,
25 ) -> Self {
26 Self::Download {
27 event: DownloadEvent::progress(id, downloaded, total, speed_bps, eta_seconds),
28 }
29 }
30
31 pub fn download_completed(id: impl Into<String>, message: Option<String>) -> Self {
33 Self::Download {
34 event: DownloadEvent::completed(id, message),
35 }
36 }
37
38 pub fn download_failed(id: impl Into<String>, error: impl Into<String>) -> Self {
40 Self::Download {
41 event: DownloadEvent::failed(id, error),
42 }
43 }
44
45 pub fn download_cancelled(id: impl Into<String>) -> Self {
47 Self::Download {
48 event: DownloadEvent::cancelled(id),
49 }
50 }
51}