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(
16 id: impl Into<String>,
17 downloaded: u64,
18 total: u64,
19 speed_bps: f64,
20 eta_seconds: f64,
21 percentage: f64,
22 ) -> Self {
23 let _ = (eta_seconds, percentage); Self::Download {
25 event: DownloadEvent::progress(id, downloaded, total, speed_bps),
26 }
27 }
28
29 pub fn download_completed(id: impl Into<String>, message: Option<String>) -> Self {
31 Self::Download {
32 event: DownloadEvent::completed(id, message),
33 }
34 }
35
36 pub fn download_failed(id: impl Into<String>, error: impl Into<String>) -> Self {
38 Self::Download {
39 event: DownloadEvent::failed(id, error),
40 }
41 }
42
43 pub fn download_cancelled(id: impl Into<String>) -> Self {
45 Self::Download {
46 event: DownloadEvent::cancelled(id),
47 }
48 }
49}